Skip to content
Snippets Groups Projects
Commit be4a6bd7 authored by Lukas Maruniak's avatar Lukas Maruniak
Browse files

Added view all page

parent 8a3962c8
No related merge requests found
......@@ -40,4 +40,13 @@ public class DocumentController {
return "view-pdf";
}
@GetMapping("/view")
public String viewPdf(Model model) {
var references = documentService.getAllReferences();
model.addAttribute("references", references);
return "view-all";
}
}
......@@ -35,6 +35,11 @@ public class DocumentService {
return documentMapper.toSimpleDocumentList(documentRepository.getReferencedDocumentsById(id));
}
@Transactional
public List<SimpleDocumentDto> getAllReferences() {
return documentMapper.toSimpleDocumentList(documentRepository.findAll());
}
@Transactional
public Dokument saveDocument(Dokument document) {
Dokument dok = new Dokument();
......
<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Upload PDF</title>
<script src="https://code.jquery.com/jquery-3.6.0.min.js"></script>
<style>
#pdf-preview {
width: 500px;
height: 600px;
border: 1px solid #ddd;
margin-top: 10px;
}
</style>
</head>
<body>
<h1>PDF files</h1>
<!-- zobrazenie PDF -->
<div id="pdf-container">
<iframe id="pdf-preview" src="" style="display: none;"></iframe>
</div>
<table>
<thead>
<tr>
<th>ID</th>
<th>Title</th>
<th>Link</th>
</tr>
</thead>
<tbody>
<tr th:each="ref: ${references}">
<td th:text="${ref.id}"></td>
<td th:text="${ref.title}"></td>
<td><a th:href="@{'/api/document/' + ${ref.id}}" th:text="${ref.title}"></a></td>
</tr>
</tbody>
</table>
</body>
</html>
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment