Commit d6d38cb5 authored by Matija Obreza's avatar Matija Obreza

Merge branch '123-fix-all-crops-list-page' into 'master'

Resolve "Fix all crops list page"

Closes #123

See merge request !83
parents 32f4ce9f ac5ea2e4
......@@ -60,6 +60,9 @@ public interface AccessionRepository extends JpaRepository<Accession, Long>, Acc
@Query("select count(a) from Accession a where a.institute.country = ?1 and a.historic = false")
long countByLocation(Country country);
@Query("select count(a) from Accession a where a.crop = ?1 and a.historic = false")
long countByCrop(Crop crop);
@Query(value = "select a.cropName, count(a.id) from Accession a where a.institute = ?1 and a.historic = false group by a.cropName order by count(a) desc", countQuery = "select count(distinct a.cropName) from Accession a where a.institute = ?1")
Page<Object[]> statisticsCropNameInInstitute(FaoInstitute institute, Pageable pageable);
......
......@@ -183,6 +183,8 @@ public interface GenesysService {
long countAllActive();
long countAllHistoric();
long countByCrop(Crop crop);
/**
* For institutes with {@link FaoInstitute#uniqueAcceNumbs}
......
......@@ -248,7 +248,12 @@ public class GenesysServiceImpl implements GenesysService, DatasetService {
return accessionRepository.countByHistoric(true);
}
@Override
@Override
public long countByCrop(final Crop crop) {
return accessionRepository.countByCrop(crop);
}
@Override
public long countByInstitute(FaoInstitute institute) {
return accessionRepository.countByInstitute(institute);
}
......
......@@ -18,7 +18,9 @@ package org.genesys2.server.servlet.controller;
import java.io.IOException;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
import org.elasticsearch.common.lang3.StringUtils;
......@@ -29,6 +31,7 @@ import org.genesys2.server.service.ContentService;
import org.genesys2.server.service.CropService;
import org.genesys2.server.service.FilterConstants;
import org.genesys2.server.service.GenesysService;
import org.genesys2.server.service.StatisticsService;
import org.genesys2.server.service.TraitService;
import org.genesys2.server.service.impl.FilterHandler;
import org.genesys2.server.service.impl.FilterHandler.AppliedFilter;
......@@ -68,10 +71,22 @@ public class CropController extends BaseController {
@Autowired
private TraitService traitService;
@Autowired
private StatisticsService statisticsService;
@RequestMapping(value = "/", method = RequestMethod.GET)
public String index(ModelMap model) {
_logger.debug("Viewing all crops");
model.addAttribute("crops", cropService.list(getLocale()));
List<Crop> cropList = cropService.list(getLocale());
Map<Crop, Long> map = new HashMap<>();
for (Crop crop : cropList) {
map.put(crop, genesysService.countByCrop(crop));
}
model.addAttribute("cropsMap", map);
model.addAttribute("numberOfCountries", statisticsService.numberOfCountries());
model.addAttribute("numberOfInstitutes", statisticsService.numberOfInstitutes());
model.addAttribute("numberOfActiveAccessions", statisticsService.numberOfActiveAccessions());
return "/crop/list";
}
......
......@@ -152,8 +152,10 @@ userprofile.page.ftp-credentials=Your FTP credentials are:
user.page.list.title=Registered user accounts
crop.crops-directory=Genesys crops directory
crop.croplist=Crop list
crop.all-crops=All crops
crop.crops=Crops
crop.taxonomy-rules=Taxonomic rules
crop.view-descriptors=View crop descriptors...
crop.page.edit.title=Edit {0}
......@@ -682,6 +684,8 @@ autocomplete.genus=Find Genus...
stats.number-of-countries={0} Countries
stats.number-of-institutes={0} Institutes
stats.number-of-accessions={0} Accessions
stats.number-of-crops={0} Crops
stats.number-of-datasets={0} Datasets
stats.number-of-historic-accessions={0} Historic accessions
navigate.back=Back
......
......@@ -1276,7 +1276,6 @@ $light-font-family: 'Roboto-Light';
line-height: 20px;
}
}
}
.header-search {
......@@ -1367,6 +1366,155 @@ $light-font-family: 'Roboto-Light';
}
//LTR and RTL rules outside genesys-page class
//crop-list-table
.crop-header {
background: #D4D2C7;
padding: 15px 0px;
}
.crop-header-bottom {
background: #D4D2C7;
padding: 25px 0px;
}
.crop-hr {
border-top: 1px solid #B2AFA6;
margin: 0 -15px;
}
.bold {
font-weight: bold;
}
.crop-title-wrap {
padding: 0 5px;
@media (max-width: 767px) {
display: block;
}
}
.crop-title {
font-size: 17px;
}
.divider {
@media (max-width: 767px) {
display: none;
}
}
#crop-list-titles {
&.container {
padding-bottom: 20px;
padding-top: 10px;
@media (min-width: 600px) and (max-width: 767px) {
max-width: 500px;
}
@media (min-width: 1200px) {
width: 1150px;
}
@media (min-width: 1520px) {
width: 1470px;
}
@media (max-width: 499px) {
max-width: 320px;
}
}
.crop-wrap {
padding-top: 7px;
text-align: center;
margin: 10px 11px 10px;
background: #fff;
box-shadow: 0px 1px 5px 0px rgba(0, 0, 0, 0.1), 0px 2px 2px 0px rgba(0, 0, 0, 0.1), 0px 1px 1px -1px rgba(0, 0, 0, 0.1);
@media (max-width: 499px){
margin: 10px 0px 10px;
}
& > a {
position: absolute;
left: 0;
right: 0;
top: 0;
bottom: 0;
z-index: 10;
}
.crop-inner-hr {
border-top: 1px solid #D4D4D4;
margin: 0 -15px;
}
}
.col-xs-6 {
width: 100%;
@media (min-width: 500px) {
width: 45.1%;
}
}
.col-sm-3 {
@media (min-width: 768px){
width: 30.2%;
}
@media (min-width: 992px){
width: 22.6%;
}
}
.col-lg-2 {
@media (min-width: 1200px){
width: 22.9%;
}
@media (min-width: 1520px){
width: 14.7%;
}
}
img {
margin: 0 auto;
background: #fff;
font-size: 0;
}
.img-wrap {
background-image: url(../images/ICON-MISSING.svg);
width: 60px;
height: 60px;
max-height: 110px;
margin: 0 auto;
@media (min-width: 768px) {
width: 60px;
height: 60px;
}
@media (max-width: 767px) and (min-width: 500px) {
width: 90px;
height: 90px;
}
@media (max-width: 499px) {
width: 80px;
height: 80px;
}
}
p {
color: #006db4;
font-size: 19px;
margin: 0 0 7px;
}
span {
color: #999;
font-size: 11px;
padding: 6px 0 8px;
display: inline-block;
}
}
//header
#navbar .header-search form.form-inline .form-group:before {
html[dir="ltr"] & {
......
......@@ -3,31 +3,59 @@
<%@ include file="/WEB-INF/jsp/init.jsp" %>
<html>
<head>
<title><spring:message code="crop.croplist" /></title>
</head>
<body>
<h1>
<spring:message code="crop.croplist" />
</h1>
<ul class="funny-list">
<c:forEach items="${crops}" var="crop" varStatus="status">
<li class="clearfix ${status.count % 2 == 0 ? 'even' : 'odd'}">
<div class="row">
<div class="col-xs-4">
<a class="show pull-left" href="<c:url value="/c/${crop.shortName}" />"><c:out value="${crop.getName(pageContext.response.locale)}" /></a>
</div>
<div class="col-xs-8">
<span style="margin: 0 1em; white-space: nowrap;"><c:out value="${crop.shortName}" /></span>
<c:forEach items="${crop.otherNames}" var="otherName">
<span style="margin: 0 1em; white-space: nowrap;"><c:out value="${otherName}" /></span>
</c:forEach>
</div>
</div>
</li>
</c:forEach>
</ul>
</body>
<head>
<title><spring:message code="crop.croplist" /></title>
</head>
<body>
<div class="informative-h1 green-bg row">
<div class="col-xs-12">
<h1>
<spring:message code="crop.croplist" />
</h1>
<p><spring:message code="crop.crops-directory" /></p>
</div>
</div>
<div class="row crop-header">
<div class="col-xs-12">
<span class="bold crop-title crop-title-wrap">Summary</span>
<span class="divider">|</span>
<span class="crop-title-wrap">
<span class="bold"><fmt:formatNumber value = "${cropsMap.size()}" type = "number"/></span>
<span class="crop-title"><spring:message code="crop.crops" /></span>
</span>
<span class="divider">|</span>
<span class="crop-title-wrap">
<span class="bold"><fmt:formatNumber value = "${numberOfActiveAccessions}" type = "number"/></span>
<span class="crop-title"><spring:message code="search.section.accession" /></span>
</span>
<span class="divider">|</span>
<span class="crop-title-wrap">
<span class="bold"><fmt:formatNumber value = "${numberOfInstitutes}" type = "number"/></span>
<span class="crop-title"><spring:message code="menu.institutes" /></span></span>
</span>
<span class="divider">|</span>
<span class="crop-title-wrap">
<span class="bold"><fmt:formatNumber value = "${numberOfCountries}" type = "number"/></span>
<span class="crop-title"><spring:message code="menu.countries"/></span>
</span>
</div>
</div>
<hr class="crop-hr">
<div class="row">
<div id="crop-list-titles" class="container">
<c:forEach var="entry" items="${cropsMap}">
<div class="col-xs-6 col-sm-3 col-lg-2 crop-wrap">
<a class="fff" href="<c:url value="/c/${entry.key.shortName}" />"></a>
<div class="img-wrap">
<img class="img-responsive icon" src="/html/1/images/<c:out value="${entry.key.shortName}"/>.png" alt="<c:out value="${entry.key.shortName}"/>"/>
</div>
<p class="bold"><c:out value="${entry.key.getName(pageContext.response.locale)}" /></p>
<hr class="crop-inner-hr">
<span><fmt:formatNumber value = "${entry.value}" type = "number"/> <spring:message code="search.section.accession" /></span>
</div>
</c:forEach>
</div>
</div>
<div class="row crop-header-bottom"></div>
</body>
</html>
\ No newline at end of file
......@@ -22,7 +22,7 @@
</div>
</c:if>
</div>
</div>
</div>
</div>
<div class="row no-space map">
......@@ -108,7 +108,7 @@
</div>
</div>
<!-- Block Help -->
<div class="col-md-4 col-sm-12 col-xs-12 no-space">
<div class="see-also-block">
......@@ -171,8 +171,8 @@
<cms:blurb blurb="${sideBlurp}"/>
</div>
</c:if>
<div class="content-block" id="crop-list">
<h2 class="short text-right pull-left">
<spring:message code="crop.croplist" />
......@@ -195,21 +195,21 @@
<div class="row">
<div class="col-md-12 col-sm-12 col-xs-12">
<li class="all-crops">
<a class="show" href="<c:url value="/explore/" />">
<a class="show" href="<c:url value="/c/" />">
<spring:message code="crop.all-crops" />
</a>
</li>
<c:forEach items="${cropList}" var="crop" varStatus="status">
<li>
<a class="show" href="<c:url value="/c/${crop.shortName}" />">
<c:out value="${crop.getName(pageContext.response.locale)}" />
</a>
</li>
<c:if test="${status.count % Math.round(cropCount / 3) == 0}">
</div>
<div class="col-md-12 col-sm-12 col-xs-12">
</c:if>
</c:forEach>
<c:forEach items="${cropList}" var="crop" varStatus="status">
<li>
<a class="show" href="<c:url value="/c/${crop.shortName}" />">
<c:out value="${crop.getName(pageContext.response.locale)}" />
</a>
</li>
<c:if test="${status.count % Math.round(cropCount / 3) == 0}">
</div>
<div class="col-md-12 col-sm-12 col-xs-12">
</c:if>
</c:forEach>
</div>
</div>
</ul>
......@@ -218,8 +218,8 @@
</c:if>
</div>
</div>
<content tag="javascript">
<!-- Index Javascripts -->
<script type="text/javascript">
......@@ -233,8 +233,8 @@
$('#home-li').find("a").addClass('active active-group');
$('#home-li').addClass('active');
$(".autocomplete-genus").each(function() {
var t=$(this);
t.autocomplete({ delay: 200, minLength: 3, source: t.attr('x-source'),
var t=$(this);
t.autocomplete({ delay: 200, minLength: 3, source: t.attr('x-source'),
messages: { noResults: '', results: function() {} },
select: function(event, ui) { document.location.pathname='/acn/t/'+ui.item.value; } });
});
......@@ -243,4 +243,4 @@
</content>
</body>
</html>
\ No newline at end of file
</html>
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