Commit f6a2c78f authored by Matija Obreza's avatar Matija Obreza

Show accession image gallery

parent 321f7a0f
......@@ -73,7 +73,6 @@ public class InstituteFilesServiceImpl implements InstituteFilesService {
}
@Override
@PreAuthorize("hasRole('ADMINISTRATOR') or hasPermission(#institute, 'WRITE') or hasPermission(#institute, 'CREATE')")
public ImageGallery loadImageGallery(final FaoInstitute institute, final Accession accession) {
final String path = getGalleryPath(institute, accession);
return this.imageGalleryService.loadImageGallery(path);
......
......@@ -20,6 +20,8 @@ import java.util.ArrayList;
import java.util.List;
import java.util.UUID;
import org.genesys2.server.filerepository.model.ImageGallery;
import org.genesys2.server.filerepository.service.ImageGalleryService;
import org.genesys2.server.model.dataset.DS;
import org.genesys2.server.model.genesys.Accession;
import org.genesys2.server.model.genesys.AccessionGeo;
......@@ -27,10 +29,10 @@ import org.genesys2.server.model.genesys.PDCI;
import org.genesys2.server.model.genesys.Taxonomy2;
import org.genesys2.server.model.impl.Crop;
import org.genesys2.server.model.impl.FaoInstitute;
import org.genesys2.server.service.CropService;
import org.genesys2.server.service.DSService;
import org.genesys2.server.service.FilterConstants;
import org.genesys2.server.service.GenesysService;
import org.genesys2.server.service.InstituteFilesService;
import org.genesys2.server.service.InstituteService;
import org.genesys2.server.service.StatisticsService;
import org.genesys2.server.service.TaxonomyService;
......@@ -63,9 +65,6 @@ public class AccessionController extends BaseController {
@Autowired
private TaxonomyService taxonomyService;
@Autowired
private CropService cropService;
@Autowired
private DSService dsService;
......@@ -74,7 +73,14 @@ public class AccessionController extends BaseController {
@Autowired
private StatisticsService statisticsService;
@Autowired
private InstituteFilesService instituteFilesService;
@Autowired
private ImageGalleryService imageGalleryService;
@RequestMapping("/id/{accessionId}")
public String view(ModelMap model, @PathVariable(value = "accessionId") long accessionId) {
_logger.debug("Viewing ACN " + accessionId);
......@@ -138,6 +144,13 @@ public class AccessionController extends BaseController {
_logger.warn(e.getMessage(), e);
}
}
final ImageGallery imageGallery = this.instituteFilesService.loadImageGallery(accession.getInstitute(), accession);
if (imageGallery != null) {
imageGalleryService.ensureThumbnails(imageGallery, 200, 200);
model.addAttribute("thumbnailFormat", "200x200");
model.addAttribute("imageGallery", imageGallery);
}
return "/accession/details";
}
......
......@@ -364,6 +364,8 @@ accession.svalbard-data.boxNumber=Box number
accession.svalbard-data.quantity=Quantity
accession.remarks=Remarks
accession.imageGallery=Accession images
taxonomy.genus=Genus
taxonomy.species=Species
taxonomy.taxonName=Scientific name
......
......@@ -336,6 +336,23 @@
</div>
</c:if>
<c:if test="${imageGallery ne null}">
<h4>
<spring:message code="accession.imageGallery" />
</h4>
<div class="row" id="imagegallery-thumbs">
<c:forEach items="${imageGallery.images}" var="image">
<div x-src="<c:out value="${image.uuid}${image.extension}" />" style="cursor: pointer;" class="col-xs-6 col-sm-3 col-md-2 col-lg-2">
<img style="width: 100%;" src="<c:url value="/repository/d${image.path}_thumb/${thumbnailFormat}_${image.uuid}.png" />" alt="${image.title}" />
</div>
</c:forEach>
</div>
<div class="imagegallery-image-frame row text-center">
<img style="width: 100%;" id="imagegallery-image" />
</div>
</c:if>
<c:if test="${accessionCollect ne null}">
<h4>
<spring:message code="accession.collecting" />
......@@ -793,7 +810,22 @@
});
</script>
</c:if>
<c:if test="${imageGallery ne null}">
<script type="text/javascript">
$(document).ready(function() {
var imageViewer=$('#imagegallery-image')[0];
var baseHref = '<c:url value="/repository/d${imageGallery.path}" />';
var galleryImages = $('#imagegallery-thumbs div');
if (galleryImages.length > 0) {
imageViewer.src = baseHref + $(galleryImages[0]).attr('x-src');
}
$('#imagegallery-thumbs div').click(function(ev) {
imageViewer.src = baseHref + $(this).attr('x-src');
});
});
</script>
</c:if>
<script type="text/javascript">
<%@include file="/WEB-INF/jsp/wiews/ga.jsp"%>
_pageDim = { institute: '${accession.instituteCode}', genus: '${accession.taxonomy.genus}' };
......
Markdown is supported
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