Commit 20d8adb8 authored by Maxym Borodenko's avatar Maxym Borodenko Committed by Matija Obreza
Browse files

Respect Institute files permissions

- Fixed incorrect parameters from the edit page. Changed redirect path after updating file metadata.
parent ce6e1879
...@@ -36,6 +36,7 @@ public interface InstituteService { ...@@ -36,6 +36,7 @@ public interface InstituteService {
FaoInstitute getInstitute(String wiewsCode); FaoInstitute getInstitute(String wiewsCode);
FaoInstitute findInstitute(String wiewsCode); FaoInstitute findInstitute(String wiewsCode);
FaoInstitute getInstituteForEdit(String wiewsCode);
List<FaoInstitute> getInstitutes(Collection<String> wiewsCodes); List<FaoInstitute> getInstitutes(Collection<String> wiewsCodes);
......
...@@ -46,6 +46,7 @@ import org.springframework.data.domain.PageRequest; ...@@ -46,6 +46,7 @@ import org.springframework.data.domain.PageRequest;
import org.springframework.data.domain.Pageable; import org.springframework.data.domain.Pageable;
import org.springframework.data.domain.Sort; import org.springframework.data.domain.Sort;
import org.springframework.data.domain.Sort.Direction; import org.springframework.data.domain.Sort.Direction;
import org.springframework.security.access.prepost.PostAuthorize;
import org.springframework.security.access.prepost.PreAuthorize; import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.security.acls.domain.BasePermission; import org.springframework.security.acls.domain.BasePermission;
import org.springframework.security.core.userdetails.UserDetails; import org.springframework.security.core.userdetails.UserDetails;
...@@ -111,7 +112,19 @@ public class InstituteServiceImpl implements InstituteService { ...@@ -111,7 +112,19 @@ public class InstituteServiceImpl implements InstituteService {
return inst; return inst;
} }
@Override /**
* Returns institute if user has required permissions
*
* @param wiewsCode code
* @return institute
*/
@Override
@PostAuthorize("hasRole('ADMINISTRATOR') or hasPermission(returnObject, 'ADMINISTRATION')")
public FaoInstitute getInstituteForEdit(final String wiewsCode) {
return instituteRepository.findByCode(wiewsCode);
}
@Override
public List<FaoInstitute> listByCountry(Country country) { public List<FaoInstitute> listByCountry(Country country) {
return instituteRepository.listByCountry(country, new Sort("code")); return instituteRepository.listByCountry(country, new Sort("code"));
} }
......
...@@ -464,8 +464,7 @@ public class WiewsController extends BaseController { ...@@ -464,8 +464,7 @@ public class WiewsController extends BaseController {
/* File management */ /* File management */
@PreAuthorize("hasRole('ADMINISTRATOR')") @GetMapping(value = "/{wiewsCode}/files/**")
@RequestMapping(value = "/{wiewsCode}/files/**", method = RequestMethod.GET)
public String listAllFiles(HttpServletRequest request, ModelMap model) throws UnsupportedEncodingException, InvalidRepositoryPathException { public String listAllFiles(HttpServletRequest request, ModelMap model) throws UnsupportedEncodingException, InvalidRepositoryPathException {
String fullpath = (String) request.getAttribute(HandlerMapping.PATH_WITHIN_HANDLER_MAPPING_ATTRIBUTE); String fullpath = (String) request.getAttribute(HandlerMapping.PATH_WITHIN_HANDLER_MAPPING_ATTRIBUTE);
// The /** mapping does not decode the URL // The /** mapping does not decode the URL
...@@ -474,17 +473,19 @@ public class WiewsController extends BaseController { ...@@ -474,17 +473,19 @@ public class WiewsController extends BaseController {
return listAllFiles(model, fullpath); return listAllFiles(model, fullpath);
} }
@PreAuthorize("hasRole('ADMINISTRATOR')") @GetMapping(value = "/{path}/files")
@RequestMapping(value = "/{path}/files", method = RequestMethod.GET)
public String listAllFiles(ModelMap model, @PathVariable(value = "path") String path) throws InvalidRepositoryPathException { public String listAllFiles(ModelMap model, @PathVariable(value = "path") String path) throws InvalidRepositoryPathException {
final String repositoryPath = path.contains("/wiews/") ? path.replace("/files/", "/") : "/wiews/" + path; final String repositoryPath = path.contains("/wiews/") ? path.replace("/files/", "/") : "/wiews/" + path;
String wiewsCode = path.replace("/wiews/", "");
wiewsCode = wiewsCode.contains("/") ? wiewsCode.substring(0, wiewsCode.indexOf("/")) : wiewsCode;
//check user permissions
instituteService.getInstituteForEdit(wiewsCode);
if (LOG.isDebugEnabled()) { if (LOG.isDebugEnabled()) {
LOG.debug("Listing files for path={}", repositoryPath); LOG.debug("Listing files for path={}", repositoryPath);
} }
String wiewsCode = path.replace("/wiews/", "");
wiewsCode = wiewsCode.contains("/") ? wiewsCode.substring(0, wiewsCode.indexOf("/")) : wiewsCode;
List<String> subPaths = new ArrayList<>(); List<String> subPaths = new ArrayList<>();
for (String subPath: repositoryService.listPaths(repositoryPath, new PageRequest(0, 10))) { for (String subPath: repositoryService.listPaths(repositoryPath, new PageRequest(0, 10))) {
if (!subPath.equals(repositoryPath) && subPath.contains(repositoryPath)) { if (!subPath.equals(repositoryPath) && subPath.contains(repositoryPath)) {
...@@ -501,11 +502,12 @@ public class WiewsController extends BaseController { ...@@ -501,11 +502,12 @@ public class WiewsController extends BaseController {
return MANAGE_FILES_JSP_PATH + "/index"; return MANAGE_FILES_JSP_PATH + "/index";
} }
@PreAuthorize("hasRole('ADMINISTRATOR')") @PostMapping(value = "/{wiewsCode}/upload-file")
@RequestMapping(value = "/upload-file", method = RequestMethod.POST) public String uploadFile(@RequestParam MultipartFile file, @PathVariable String wiewsCode, @RequestParam String repositoryPath,
public String uploadFile(@RequestParam MultipartFile file, @RequestParam String wiewsCode, @RequestParam String repositoryPath,
RedirectAttributes redirectAttributes) throws IOException { RedirectAttributes redirectAttributes) throws IOException {
//check user permissions
instituteService.getInstituteForEdit(wiewsCode);
final String mimeType = file.getContentType(); final String mimeType = file.getContentType();
try { try {
...@@ -529,9 +531,11 @@ public class WiewsController extends BaseController { ...@@ -529,9 +531,11 @@ public class WiewsController extends BaseController {
} }
} }
@PreAuthorize("hasRole('ADMINISTRATOR')") @PostMapping(value = "/{wiewsCode}/delete-file")
@RequestMapping(value = "/delete-file", method = RequestMethod.POST) public String deleteFile(@RequestParam String uuid, @PathVariable String wiewsCode) throws NoSuchRepositoryFileException, IOException {
public String deleteFile(@RequestParam String uuid, @RequestParam String wiewsCode) throws NoSuchRepositoryFileException, IOException { //check user permissions
instituteService.getInstituteForEdit(wiewsCode);
RepositoryFile repositoryFile = repositoryService.getFile(UUID.fromString(uuid)); RepositoryFile repositoryFile = repositoryService.getFile(UUID.fromString(uuid));
repositoryService.removeFile(repositoryFile); repositoryService.removeFile(repositoryFile);
...@@ -542,33 +546,48 @@ public class WiewsController extends BaseController { ...@@ -542,33 +546,48 @@ public class WiewsController extends BaseController {
} }
} }
@PreAuthorize("hasRole('ADMINISTRATOR')") @GetMapping(value = "/{wiewsCode}/edit-file")
@RequestMapping(value = "/{wiewsCode}/edit-file", method = RequestMethod.GET)
public String getEditPage(@RequestParam String uuid, @PathVariable(value = "wiewsCode") String wiewsCode, ModelMap model) throws NoSuchRepositoryFileException { public String getEditPage(@RequestParam String uuid, @PathVariable(value = "wiewsCode") String wiewsCode, ModelMap model) throws NoSuchRepositoryFileException {
//check user permissions
instituteService.getInstituteForEdit(wiewsCode);
RepositoryFile file = repositoryService.getFile(UUID.fromString(uuid)); RepositoryFile file = repositoryService.getFile(UUID.fromString(uuid));
String fileSubPath = file.getPath().replace("/wiews/" + wiewsCode, "");
model.addAttribute("file", file); model.addAttribute("file", file);
model.addAttribute("wiewsCode", wiewsCode); model.addAttribute("wiewsCode", wiewsCode);
model.addAttribute("fileSubPath", fileSubPath);
return MANAGE_FILES_JSP_PATH + "/edit"; return MANAGE_FILES_JSP_PATH + "/edit";
} }
@PreAuthorize("hasRole('ADMINISTRATOR')") @PostMapping(value = "/{wiewsCode}/update-file")
@RequestMapping(value = "/{wiewsCode}/update-file", method = RequestMethod.POST) public String updateMetadata(@ModelAttribute RepositoryFile fileData, @PathVariable(value = "wiewsCode") String wiewsCode) throws NoSuchRepositoryFileException {
public String updateMetadata(@ModelAttribute RepositoryFile fileData, @RequestParam String uuid, @PathVariable(value = "wiewsCode") String wiewsCode) throws NoSuchRepositoryFileException { //check user permissions
RepositoryFile updatedFile = repositoryService.getFile(UUID.fromString(uuid)); instituteService.getInstituteForEdit(wiewsCode);
RepositoryFile updatedFile = repositoryService.getFile(UUID.fromString(fileData.getUuid().toString()));
repositoryService.updateMetadata(updatedFile.getUuid(), fileData); repositoryService.updateMetadata(updatedFile.getUuid(), fileData);
String fileSubPath = updatedFile.getPath().replace("/wiews/" + wiewsCode, "");
return "redirect:/wiews/" + wiewsCode + "/files"; return "redirect:/wiews/" + wiewsCode + "/files" + fileSubPath;
} }
/* Image gallery management */
@GetMapping(value = "/{wiewsCode}/files/gallery") @GetMapping(value = "/{wiewsCode}/files/gallery")
public String listAllFiles(ModelMap model, @PathVariable("wiewsCode") String wiewsCode, HttpServletRequest request) { public String listAllFiles(ModelMap model, @PathVariable("wiewsCode") String wiewsCode, HttpServletRequest request) {
return "redirect:/wiews/" + wiewsCode + "/files" + "/gallery" + "/1"; //check user permissions
instituteService.getInstituteForEdit(wiewsCode);
return "redirect:/wiews/" + wiewsCode + "/files" + "/gallery" + "/1";
} }
@GetMapping(value = "/{wiewsCode}/files/gallery/{page:\\d+}") @GetMapping(value = "/{wiewsCode}/files/gallery/{page:\\d+}")
public String listAllFiles(ModelMap model, @PathVariable("page") int page, @PathVariable("wiewsCode") String wiewsCode) { public String listAllFiles(ModelMap model, @PathVariable("page") int page, @PathVariable("wiewsCode") String wiewsCode) {
Page<ImageGallery> pagedData = imageGalleryService.listImageGalleries(new PageRequest(page - 1, 50, new Sort("path"))); //check user permissions
instituteService.getInstituteForEdit(wiewsCode);
Page<ImageGallery> pagedData = imageGalleryService.listImageGalleries("/wiews/" + wiewsCode, new PageRequest(page - 1, 50, new Sort("path")));
model.addAttribute("pagedData", pagedData); model.addAttribute("pagedData", pagedData);
model.addAttribute("wiewsCode", wiewsCode); model.addAttribute("wiewsCode", wiewsCode);
...@@ -576,9 +595,12 @@ public class WiewsController extends BaseController { ...@@ -576,9 +595,12 @@ public class WiewsController extends BaseController {
} }
@GetMapping(value = "/{wiewsCode}/files/gallery/details") @GetMapping(value = "/{wiewsCode}/files/gallery/details")
public String listAllFiles(ModelMap model, HttpServletRequest request, @PathVariable("wiewsCode") String wiewsCode) { public String listAllFiles(ModelMap model, HttpServletRequest request, @PathVariable("wiewsCode") String wiewsCode, @RequestParam String galleryPath) {
//check user permissions
instituteService.getInstituteForEdit(wiewsCode);
ImageGallery imageGallery = imageGalleryService.loadImageGallery("/wiews/" + wiewsCode); ImageGallery imageGallery = imageGalleryService.loadImageGallery(galleryPath);
String gallerySubPath = galleryPath.replace("/wiews/" + wiewsCode, "");
if (imageGallery == null) { if (imageGallery == null) {
throw new ResourceNotFoundException("No image gallery here!"); throw new ResourceNotFoundException("No image gallery here!");
...@@ -588,31 +610,37 @@ public class WiewsController extends BaseController { ...@@ -588,31 +610,37 @@ public class WiewsController extends BaseController {
model.addAttribute("thumbnailFormat", "200x200"); model.addAttribute("thumbnailFormat", "200x200");
model.addAttribute("imageGallery", imageGallery); model.addAttribute("imageGallery", imageGallery);
model.addAttribute("wiewsCode", wiewsCode); model.addAttribute("wiewsCode", wiewsCode);
model.addAttribute("gallerySubPath", gallerySubPath);
return MANAGE_FILES_JSP_PATH + "/gallery/details"; return MANAGE_FILES_JSP_PATH + "/gallery/details";
} }
@GetMapping(value = "/{path}/files/gallery/edit") @GetMapping(value = "/{wiewsCode}/files/gallery/edit")
public String getEditPage(@RequestParam String galleryPath, ModelMap model) throws NoSuchRepositoryFileException { public String getEditGalleryPage(@RequestParam String galleryPath, @PathVariable("wiewsCode") String wiewsCode, ModelMap model) throws NoSuchRepositoryFileException {
ImageGallery imageGallery = imageGalleryService.loadImageGallery(galleryPath); //check user permissions
instituteService.getInstituteForEdit(wiewsCode);
ImageGallery imageGallery = imageGalleryService.loadImageGallery(galleryPath);
if (imageGallery == null) { if (imageGallery == null) {
imageGallery = new ImageGallery(); imageGallery = new ImageGallery();
imageGallery.setPath(galleryPath); imageGallery.setPath(galleryPath);
} }
model.addAttribute("imageGallery", imageGallery); model.addAttribute("imageGallery", imageGallery);
model.addAttribute("wiewsCode", galleryPath); model.addAttribute("wiewsCode", wiewsCode);
return MANAGE_FILES_JSP_PATH + "/gallery/edit"; return MANAGE_FILES_JSP_PATH + "/gallery/edit";
} }
@PostMapping(value = "{wiewsCode}/files/gallery/update") @PostMapping(value = "{wiewsCode}/files/gallery/update")
public String updateMetadata(@PathVariable("wiewsCode") String wiewsCode, @ModelAttribute ImageGallery imageGallery, RedirectAttributes redirectAttributes) throws NoSuchRepositoryFileException { public String updateMetadata(@PathVariable("wiewsCode") String wiewsCode, @ModelAttribute ImageGallery imageGallery, RedirectAttributes redirectAttributes) throws NoSuchRepositoryFileException {
//check user permissions
instituteService.getInstituteForEdit(wiewsCode);
ImageGallery updatedGallery = imageGalleryService.loadImageGallery(imageGallery.getPath()); ImageGallery updatedGallery = imageGalleryService.loadImageGallery(imageGallery.getPath());
if (updatedGallery == null) { if (updatedGallery == null) {
updatedGallery = imageGalleryService.createImageGallery(imageGallery.getPath(), imageGallery.getTitle(), imageGallery.getDescription()); imageGalleryService.createImageGallery(imageGallery.getPath(), imageGallery.getTitle(), imageGallery.getDescription());
} else { } else {
updatedGallery = imageGalleryService.updateImageGalery(updatedGallery, imageGallery.getTitle(), imageGallery.getDescription()); imageGalleryService.updateImageGalery(updatedGallery, imageGallery.getTitle(), imageGallery.getDescription());
} }
redirectAttributes.addFlashAttribute("successMessage", "repository.gallery.successfully-updated"); redirectAttributes.addFlashAttribute("successMessage", "repository.gallery.successfully-updated");
...@@ -621,8 +649,10 @@ public class WiewsController extends BaseController { ...@@ -621,8 +649,10 @@ public class WiewsController extends BaseController {
@PostMapping(value = "{wiewsCode}/files/gallery/delete") @PostMapping(value = "{wiewsCode}/files/gallery/delete")
public String deleteFile(@RequestParam String galleryPath, RedirectAttributes redirectAttributes, @PathVariable("wiewsCode") String wiewsCode) throws InvalidRepositoryPathException { public String deleteFile(@RequestParam String galleryPath, RedirectAttributes redirectAttributes, @PathVariable("wiewsCode") String wiewsCode) throws InvalidRepositoryPathException {
//check user permissions
instituteService.getInstituteForEdit(wiewsCode);
ImageGallery imageGallery = imageGalleryService.loadImageGallery(galleryPath); ImageGallery imageGallery = imageGalleryService.loadImageGallery(galleryPath);
imageGalleryService.removeGallery(imageGallery); imageGalleryService.removeGallery(imageGallery);
redirectAttributes.addFlashAttribute("successMessage", "repository.gallery.removed"); redirectAttributes.addFlashAttribute("successMessage", "repository.gallery.removed");
......
...@@ -8,7 +8,7 @@ ...@@ -8,7 +8,7 @@
</head> </head>
<body> <body>
<h4>Updating metadata for file <strong><c:out value="${file.originalFilename}"/></strong></h4> <h4>Updating metadata for file <strong><c:out value="${file.originalFilename}"/></strong></h4>
<a href="<c:url value="/wiews/${wiewsCode}/files" />" class="btn btn-default margin-top-10"> <a href="<c:url value="/wiews/${wiewsCode}/files${fileSubPath}" />" class="btn btn-default margin-top-10">
<spring:message code="cancel"/> <spring:message code="cancel"/>
</a> </a>
...@@ -19,6 +19,7 @@ ...@@ -19,6 +19,7 @@
<input type="hidden" name="md5Sum" value="${file.md5Sum}"/> <input type="hidden" name="md5Sum" value="${file.md5Sum}"/>
<input type="hidden" name="sha1Sum" value="${file.sha1Sum}"/> <input type="hidden" name="sha1Sum" value="${file.sha1Sum}"/>
<input type="hidden" name="path" value="${file.path}"/> <input type="hidden" name="path" value="${file.path}"/>
<input type="hidden" name="id" value="${file.id}"/>
<div class="row"> <div class="row">
<div class="col-md-6 margin-top-20"> <div class="col-md-6 margin-top-20">
...@@ -35,8 +36,7 @@ ...@@ -35,8 +36,7 @@
<div class="col-md-12 margin-top-20"> <div class="col-md-12 margin-top-20">
<label for="description"><spring:message code="repository.file.description"/></label> <label for="description"><spring:message code="repository.file.description"/></label>
<textarea id="description" name="description" class="form-control"><c:out escapeXml="false" <textarea id="description" name="description" class="form-control"><c:out escapeXml="false" value="${file.description}"/></textarea>
value="${file.description}"/></textarea>
</div> </div>
<div class="col-md-6 margin-top-20"> <div class="col-md-6 margin-top-20">
...@@ -47,7 +47,7 @@ ...@@ -47,7 +47,7 @@
<div class="col-md-6 margin-top-20"> <div class="col-md-6 margin-top-20">
<label for="created"><spring:message code="repository.file.created"/></label> <label for="created"><spring:message code="repository.file.created"/></label>
<input type="text" id="created" name="created" class="form-control" value="${file.created}" <input type="text" id="created" name="created" class="form-control" value="${file.createdDate}"
placeholder="<spring:message code="repository.file.created" />"> placeholder="<spring:message code="repository.file.created" />">
</div> </div>
...@@ -108,7 +108,7 @@ ...@@ -108,7 +108,7 @@
</div> </div>
</div> </div>
<button type="submit" class="btn btn-primary margin-top-20">Save</button> <button type="submit" class="btn btn-primary margin-top-20"><spring:message code="save" /></button>
</form> </form>
</body> </body>
</html> </html>
...@@ -13,9 +13,10 @@ ...@@ -13,9 +13,10 @@
<div class="free-text"> <div class="free-text">
<c:out value="${imageGallery.description}"/> <c:out value="${imageGallery.description}"/>
</div> </div>
<a href="<c:url value="/wiews/${wiewsCode}/files/gallery" />" class="btn btn-default"><spring:message code="cancel"/></a> <div class="margin-top-20">
<a href="<c:url value="/wiews/${wiewsCode}/files" />" class="btn btn-default"><spring:message code="navigate.back"/></a> <a href="<c:url value="/wiews/${wiewsCode}/files/gallery" />" class="btn btn-default"><spring:message code="cancel"/></a>
<a href="<c:url value="/wiews/${wiewsCode}/files${gallerySubPath}" />" class="btn btn-default"><spring:message code="navigate.back"/></a>
</div>
<div class="row" id="imagegallery-thumbs"> <div class="row" id="imagegallery-thumbs">
<c:forEach items="${imageGallery.images}" var="image"> <c:forEach items="${imageGallery.images}" var="image">
<div x-src="<c:out value="${image.storageFullPath}" />" class="col-xs-6 col-sm-3 col-md-2 col-lg-2"> <div x-src="<c:out value="${image.storageFullPath}" />" class="col-xs-6 col-sm-3 col-md-2 col-lg-2">
......
...@@ -9,40 +9,39 @@ ...@@ -9,40 +9,39 @@
<body> <body>
<div class="row"> <div class="row">
<div class="col-md-12"> <div class="col-md-12">
<a href="<c:url value="${wiewsCode}/files/gallery" />" class="btn btn-default"><spring:message <div class="margin-top-20">
code="cancel" /></a> <a href="<c:url value="/wiews/${wiewsCode}/files/gallery" />" class="btn btn-default"><spring:message code="cancel" /></a>
</div>
<h4> <h4>
Updating metadata for image gallery Updating metadata for image gallery
<c:out value="${imageGallery.path}" /> <strong><c:out value="${imageGallery.path}" /></strong>
</h4> </h4>
<form action="<c:url value="${wiewsCode}/files/gallery/update" />" method="post"> <form action="<c:url value="/wiews/${wiewsCode}/files/gallery/update" />" method="post">
<input type="hidden" name="${_csrf.parameterName}" value="${_csrf.token}" /> <input type="hidden" name="${_csrf.parameterName}" value="${_csrf.token}" />
<input type="hidden" name="path" value="<c:out value="${imageGallery.path}" />"> <input type="hidden" name="path" value="<c:out value="${imageGallery.path}" />">
<div class="form-group"> <div class="row">
<label for="title"><spring:message <div class="col-md-6 margin-top-20">
code="repository.gallery.title" /></label> <input type="text" id="title" <label for="title"><spring:message code="repository.gallery.title" /></label>
name="title" value="<c:out value="${imageGallery.title}" />" <input type="text" class="form-control" id="title" name="title" value="<c:out value="${imageGallery.title}" />">
class="form-control"> </div>
</div>
<div class="col-md-6 margin-top-20">
<div class="form-group"> <label><spring:message code="repository.gallery.path" /></label>
<label for="title"><spring:message <input type="text" disabled class="form-control" value="<c:out value="${imageGallery.path}" />">
code="repository.gallery.path" /></label> <span class=""><c:out </div>
value="${imageGallery.path}" /></span>
</div> <div class="col-md-12 margin-top-20">
<label for="description"><spring:message code="repository.gallery.description" /></label>
<div class="form-group"> <textarea id="description" name="description" class="form-control"><c:out escapeXml="true" value="${imageGallery.description}" /></textarea>
<label for="subject"><spring:message </div>
code="repository.gallery.description" /></label> </div>
<textarea id="description" name="description" class="form-control"><c:out
escapeXml="false" value="${imageGallery.description}" /></textarea> <div class="margin-top-20">
</div> <button type="submit" class="btn btn-primary"><spring:message code="save" /></button>
</div>
<button type="submit" class="btn btn-default">
<spring:message code="save" />
</button>
</form> </form>
</div> </div>
</div> </div>
......
...@@ -15,28 +15,28 @@ ...@@ -15,28 +15,28 @@
<c:out value="${successMessage}" /> <c:out value="${successMessage}" />
</gui:alert> </gui:alert>
<table class="table table-striped"> <table class="table table-striped margin-top-20">
<thead> <thead>
<tr> <tr>
<th class="col-xs-5"><spring:message <th class="col-xs-5"><spring:message code="repository.gallery" /></th>
code="repository.gallery" /></th> <th class="col-xs-3"><spring:message code="repository.gallery.path" /></th>
<th class="col-xs-3"><spring:message
code="repository.gallery.path" /></th>
<th class="col-xs-4"></th> <th class="col-xs-4"></th>
</tr> </tr>
</thead> </thead>
<tbody> <tbody>
<c:forEach var="gallery" items="${pagedData.content}" varStatus="i"> <c:forEach var="gallery" items="${pagedData.content}" varStatus="i">
<tr> <tr>
<td class="col-md-5"><a href="<c:url value="/wiews/${wiewsCode}/files/gallery/details" />"><c:out value="${gallery.title}" /></a></td> <td class="col-md-5">
<a href="<c:url value="/wiews/${wiewsCode}/files/gallery/details"><c:param name="galleryPath" value="${gallery.path}" /></c:url>">
<c:out value="${gallery.title}" />
</a>
</td>
<td class="col-md-3"><c:out value="${gallery.path}" /></td> <td class="col-md-3"><c:out value="${gallery.path}" /></td>
<td class="col-md-4 text-right"> <td class="col-md-4 text-right">
<form action="<c:url value="/wiews/${wiewsCode}/files/gallery/delete" />" <form action="<c:url value="/wiews/${wiewsCode}/files/gallery/delete" />" method="post">
method="post"> <a href="<c:url value="/wiews/${wiewsCode}/files/gallery/edit"><c:param name="galleryPath" value="${gallery.path}" /></c:url>"
<a class="btn btn-default"><spring:message code="edit" />
href="<c:url value="/wiews/${wiewsCode}/files/gallery/edit"><c:param name="galleryPath" value="${gallery.path}" /></c:url>" </a>
class="btn btn-default"><spring:message code="edit" /></a>
<input type="hidden" name="${_csrf.parameterName}" value="${_csrf.token}" /> <input type="hidden" name="${_csrf.parameterName}" value="${_csrf.token}" />
<input type="hidden" name="galleryPath" value="${gallery.path}" /> <input type="hidden" name="galleryPath" value="${gallery.path}" />
<button type="submit" name="action" value="delete-file" class="btn btn-default confirm-delete"><spring:message code="delete" /></button> <button type="submit" name="action" value="delete-file" class="btn btn-default confirm-delete"><spring:message code="delete" /></button>
...@@ -47,33 +47,17 @@ ...@@ -47,33 +47,17 @@
</tbody> </tbody>
</table> </table>
<content tag="javascript"> <script type="text/javascript"> <content tag="javascript">
$(document).ready(function() { <script type="text/javascript">
$('.confirm-delete').click(function(ev) { $(document).ready(function() {
if (! window.confirm('<spring:message code="prompt.confirm-delete" />')) { $('.confirm-delete').click(function (ev) {
ev.stopPropagation(); if (!window.confirm('<spring:message code="prompt.confirm-delete" />')) {
return false; ev.stopPropagation();
} return false;
}); }
$('#repository-menu-item').addClass('active'); });
$('#repository-menu-item').find("a").first().addClass('active');
$('.humburger-btn').on('click', function () {
setTimeout(function() {
expandGroup ($(document).width());
}, 100);
}); });
}); </script>
$(window).resize(function() { </content>
expandGroup ($(document).width());
});
function expandGroup (width) {
if (width < 1920) {
$('#repository-menu-item').addClass('open');
} else {
$('#repository-menu-item').removeClass('open');