Skip to content

Commit

Permalink
Quick fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
eceeeren committed Dec 20, 2024
1 parent 50a5007 commit c63dae2
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 30 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -249,7 +249,7 @@ public static URI publicPathForActualPath(Path path, @Nullable Long entityId) {

private static URI publicPathForActualAttachmentUnitFilePath(Path path, String filename, String id) {
if (path.toString().contains("/student")) {
return URI.create(String.format("/api/files/attachments/attachment-unit/%s/student/%s", id, filename));
return URI.create("/api/files/attachments/attachment-unit/" + id + "/student/" + filename);
}
if (!path.toString().contains("/slide")) {
return URI.create("/api/files/attachments/attachment-unit/" + id + "/" + filename);
Expand Down
15 changes: 2 additions & 13 deletions src/main/java/de/tum/cit/aet/artemis/core/web/FileResource.java
Original file line number Diff line number Diff line change
Expand Up @@ -476,7 +476,7 @@ public ResponseEntity<byte[]> getLecturePdfAttachmentsMerged(@PathVariable Long
* @return The requested file, 403 if the logged-in user is not allowed to access it, or 404 if the file doesn't exist
*/
@GetMapping("files/attachments/attachment-unit/{attachmentUnitId}/*")
@EnforceAtLeastEditor
@EnforceAtLeastTutor
public ResponseEntity<byte[]> getAttachmentUnitAttachment(@PathVariable Long attachmentUnitId) {
log.debug("REST request to get the file for attachment unit {} for students", attachmentUnitId);
AttachmentUnit attachmentUnit = attachmentUnitRepository.findByIdElseThrow(attachmentUnitId);
Expand Down Expand Up @@ -580,7 +580,7 @@ public ResponseEntity<byte[]> getAttachmentUnitStudentVersion(@PathVariable Long

// check if hidden link is available in the attachment
String studentVersion = attachment.getStudentVersion();
if (attachment.getStudentVersion() == null) {
if (studentVersion == null) {
return buildFileResponse(getActualPathFromPublicPathString(attachment.getLink()), false);
}

Expand All @@ -589,17 +589,6 @@ public ResponseEntity<byte[]> getAttachmentUnitStudentVersion(@PathVariable Long
return buildFileResponse(FilePathService.getAttachmentUnitFilePath().resolve(Path.of(attachmentUnit.getId().toString(), "student")), fileName, false);
}

/**
* Builds the response with headers, body and content type for specified path and file name
*
* @param path to the file
* @param filename the name of the file
* @return response entity
*/
private ResponseEntity<byte[]> buildFileResponse(Path path, String filename) {
return buildFileResponse(path, filename, false);
}

/**
* Builds the response with headers, body and content type for specified path containing the file name
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,40 +34,43 @@
transition: transform 0.3s;
}

.pdf-overlay {
position: absolute;
width: 100%;
height: 100%;
display: flex;
justify-content: center;
align-items: center;
font-size: 24px;
color: white;
background-color: rgba(0, 0, 0, 0.5);
z-index: 2;
transition: opacity 0.3s ease;
opacity: 0;
cursor: pointer;
}

.pdf-canvas-container:hover {
transform: scale(1.02);

button {
opacity: 1;
}

.pdf-overlay {
opacity: 1;
}

.hidden-icon {
transition: transform 0.3s;
opacity: 0;
}

.hidden-overlay {
opacity: 0 !important;
}
}

.pdf-overlay {
position: absolute;
width: 100%;
height: 100%;
display: flex;
justify-content: center;
align-items: center;
font-size: 24px;
color: white;
background-color: rgba(0, 0, 0, 0.5);
z-index: 2;
transition: opacity 0.3s ease;
opacity: 0;
cursor: pointer;
}

input[type='checkbox'] {
position: absolute;
top: -5px;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,9 @@ void testActualPathForPublicPath() {

actualPath = FilePathService.actualPathForPublicPath(URI.create("/api/files/attachments/attachment-unit/4/slide/1/1.jpg"));
assertThat(actualPath).isEqualTo(Path.of("uploads", "attachments", "attachment-unit", "4", "slide", "1", "1.jpg"));

actualPath = FilePathService.actualPathForPublicPath(URI.create("/api/files/attachments/attachment-unit/4/student/download.pdf"));
assertThat(actualPath).isEqualTo(Path.of("uploads", "attachments", "attachment-unit", "4", "student", "download.pdf"));
}

@Test
Expand Down

0 comments on commit c63dae2

Please sign in to comment.