1
0

#2 Folder sharing fixup

This commit is contained in:
2023-01-23 23:13:22 +01:00
parent 7be52466d2
commit 1cac696dde
4 changed files with 44 additions and 8 deletions

View File

@@ -83,6 +83,7 @@ public class FilesController implements InitializingBean {
model.addAttribute("sortOrder", order); model.addAttribute("sortOrder", order);
model.addAttribute("apps", this.appRegistry.getAll()); model.addAttribute("apps", this.appRegistry.getAll());
model.addAttribute("restricted", this.sessionInfo.isRestrictedSession()); model.addAttribute("restricted", this.sessionInfo.isRestrictedSession());
model.addAttribute("prefix", "");
this.webContainerSharedConfig.addDefaults(model); this.webContainerSharedConfig.addDefaults(model);
return "files/filesIndex"; return "files/filesIndex";
@@ -121,6 +122,7 @@ public class FilesController implements InitializingBean {
model.addAttribute("apps", this.appRegistry.getAll()); model.addAttribute("apps", this.appRegistry.getAll());
model.addAttribute("filename", filename); model.addAttribute("filename", filename);
model.addAttribute("restricted", this.sessionInfo.isRestrictedSession()); model.addAttribute("restricted", this.sessionInfo.isRestrictedSession());
model.addAttribute("prefix", "");
this.webContainerSharedConfig.addDefaults(model); this.webContainerSharedConfig.addDefaults(model);
return "files/rename"; return "files/rename";
@@ -148,6 +150,11 @@ public class FilesController implements InitializingBean {
return "redirect:/files/browse/" + this.locationTracker.getRelativeLocation(); 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") @GetMapping("/files/download")
public ResponseEntity downloadFile(HttpServletResponse response, String filename) { public ResponseEntity downloadFile(HttpServletResponse response, String filename) {
final Path targetPath = this.locationTracker.resolve(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("apps", this.appRegistry.getAll());
model.addAttribute("filename", filename); model.addAttribute("filename", filename);
model.addAttribute("restricted", this.sessionInfo.isRestrictedSession()); model.addAttribute("restricted", this.sessionInfo.isRestrictedSession());
model.addAttribute("prefix", "");
this.webContainerSharedConfig.addDefaults(model); this.webContainerSharedConfig.addDefaults(model);
return "files/share"; return "files/share";
@@ -271,6 +279,17 @@ public class FilesController implements InitializingBean {
return "redirect:/files/browse/" + this.locationTracker.getRelativeLocation(); 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") @GetMapping("files/shares")
public Object shares(Model model, String shareUuid) { public Object shares(Model model, String shareUuid) {
this.locationTracker.reset(); this.locationTracker.reset();
@@ -299,8 +318,9 @@ public class FilesController implements InitializingBean {
if(this.fileSystemService.isDirectory(sharedFilePath)) { if(this.fileSystemService.isDirectory(sharedFilePath)) {
this.locationTracker.setBaseDirPath(share.getPath()); this.locationTracker.setBaseDirPath(share.getPath());
this.locationTracker.resetCurrentLocation();
return "redirect:/files/browse"; return "redirect:/files/browse/";
} }
else { else {
return doShares(shareUuid); return doShares(shareUuid);
@@ -332,8 +352,9 @@ public class FilesController implements InitializingBean {
if(this.fileSystemService.isDirectory(sharedFilePath)) { if(this.fileSystemService.isDirectory(sharedFilePath)) {
this.locationTracker.setBaseDirPath(share.getPath()); this.locationTracker.setBaseDirPath(share.getPath());
this.locationTracker.resetCurrentLocation();
return "redirect:/files/browse"; return "redirect:/files/browse/";
} }
else { else {
return doShares(shareUuid); 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") @GetMapping("files/preview")
public void preview(HttpServletResponse response, String filename) { public void preview(HttpServletResponse response, String filename) {
try { 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") @GetMapping("files/gallery")
public String gallery(Model model) { public String gallery(Model model) {
try { try {
@@ -406,6 +441,7 @@ public class FilesController implements InitializingBean {
model.addAttribute("files", files); model.addAttribute("files", files);
model.addAttribute("apps", this.appRegistry.getAll()); model.addAttribute("apps", this.appRegistry.getAll());
model.addAttribute("restricted", this.sessionInfo.isRestrictedSession()); model.addAttribute("restricted", this.sessionInfo.isRestrictedSession());
model.addAttribute("prefix", "");
this.webContainerSharedConfig.addDefaults(model); this.webContainerSharedConfig.addDefaults(model);
return "files/gallery"; return "files/gallery";

View File

@@ -49,9 +49,9 @@
<td th:if="${fileEntry.directory}" class="no-mobile">d</td> <td th:if="${fileEntry.directory}" class="no-mobile">d</td>
<td th:if="${!fileEntry.directory}" class="no-mobile">-</td> <td th:if="${!fileEntry.directory}" class="no-mobile">-</td>
<td th:if="${fileEntry.directory}"> <td th:if="${fileEntry.directory}">
<a th:if="${fileEntry.name != '..'}" th:href="@{/files/browse/__${fileEntry.path}__}" <a th:if="${fileEntry.name != '..'}" th:href="@{__${prefix}__/files/browse/__${fileEntry.path}__}"
th:text="${fileEntry.name}"/> th:text="${fileEntry.name}"/>
<a th:if="${fileEntry.name == '..'}" th:href="@{/files/browse/__${fileEntry.path}__}" <a th:if="${fileEntry.name == '..'}" th:href="@{__${prefix}__/files/browse/__${fileEntry.path}__}"
th:text="${fileEntry.name}"/> th:text="${fileEntry.name}"/>
</td> </td>
<td th:if="${!fileEntry.directory && @filesFormatter.needsTruncate(fileEntry.name)}" <td th:if="${!fileEntry.directory && @filesFormatter.needsTruncate(fileEntry.name)}"
@@ -78,12 +78,12 @@
th:text="#{nbscloud.files-content-table.table.actions.delete}"/> th:text="#{nbscloud.files-content-table.table.actions.delete}"/>
</div> </div>
<div id="files-content-table-show-actions-detail-container-download"> <div id="files-content-table-show-actions-detail-container-download">
<a th:href="@{/files/download(filename=${fileEntry.name})}" <a th:href="@{__${prefix}__/files/download(filename=${fileEntry.name})}"
th:text="#{nbscloud.files-content-table.table.actions.download}"/> th:text="#{nbscloud.files-content-table.table.actions.download}"/>
</div> </div>
<div th:if="${!fileEntry.directory}" <div th:if="${!fileEntry.directory}"
id="files-content-table-show-actions-detail-container-preview"> id="files-content-table-show-actions-detail-container-preview">
<a th:href="@{/files/preview(filename=${fileEntry.name})}" <a th:href="@{__${prefix}__/files/preview(filename=${fileEntry.name})}"
th:text="#{nbscloud.files-content-table.table.actions.preview}"/> th:text="#{nbscloud.files-content-table.table.actions.preview}"/>
</div> </div>
<div id="files-content-table-show-actions-detail-container-share" <div id="files-content-table-show-actions-detail-container-share"

View File

@@ -16,7 +16,7 @@
<div id="main-container"> <div id="main-container">
<div th:replace="includes/header :: header"/> <div th:replace="includes/header :: header"/>
<div id="gallery-container"> <div id="gallery-container">
<img class="galleryImage" th:each="file : ${files}" th:src="@{/files/preview(filename=${file})}"> <img class="galleryImage" th:each="file : ${files}" th:src="@{__${prefix}__/files/preview(filename=${file})}">
</div> </div>
<div th:replace="includes/footer :: footer"/> <div th:replace="includes/footer :: footer"/>
</div> </div>

View File

@@ -28,7 +28,7 @@
</div> </div>
<div class="menu-spacer"></div> <div class="menu-spacer"></div>
<div> <div>
<a id="gallery-link" th:href="@{/files/gallery}"> <a id="gallery-link" th:href="@{__${prefix}__/files/gallery}">
<span class="icon menu-icon">&#xe3b6;</span> <span class="icon menu-icon">&#xe3b6;</span>
</a> </a>
</div> </div>