#60 added dashboard

This commit is contained in:
Nightblade73 2019-04-21 17:18:44 +04:00
parent a4ae42f072
commit ddd21dab1c
7 changed files with 32 additions and 9 deletions

View File

@ -54,6 +54,11 @@ public class ConferenceController {
conferenceFilterDto.getYear()));
}
@GetMapping("/dashboard")
public void getDashboard(ModelMap modelMap) {
modelMap.put("conferences", conferenceService.findAllActiveDto());
}
@GetMapping("/conference")
public void getConference(ModelMap modelMap, @RequestParam(value = "id") Integer id) {
if (id != null && id > 0) {

View File

@ -6,10 +6,14 @@ import org.springframework.data.repository.query.Param;
import ru.ulstu.conference.model.Conference;
import ru.ulstu.user.model.User;
import java.util.Date;
import java.util.List;
public interface ConferenceRepository extends JpaRepository<Conference, Integer> {
@Query("SELECT c FROM Conference c LEFT JOIN c.users u WHERE (:user IS NULL OR u.user = :user) " +
"AND (YEAR(c.beginDate) = :year OR :year IS NULL) ORDER BY begin_date DESC")
List<Conference> findByUserAndYear(@Param("user") User user, @Param("year") Integer year);
@Query("SELECT c FROM Conference c WHERE c.beginDate > :date")
List<Conference> findAllActive(@Param("date") Date date);
}

View File

@ -18,6 +18,7 @@ import ru.ulstu.user.service.UserService;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Date;
import java.util.List;
import static org.springframework.util.ObjectUtils.isEmpty;
@ -164,4 +165,12 @@ public class ConferenceService {
conferenceFilterDto.getYear()), ConferenceDto::new);
}
public List<ConferenceDto> findAllActiveDto() {
return convert(findAllActive(), ConferenceDto::new);
}
public List<Conference> findAllActive() {
return conferenceRepository.findAllActive(new Date());
}
}

View File

@ -38,7 +38,7 @@
<div class="form-group">
<label for="url">URL:</label>
<input class="form-control" th:field="*{url}" id="url" type="text"
placeholder="URL адрес"/>
placeholder="http://"/>
</div>
<div class="form-group">

View File

@ -16,11 +16,10 @@
</div>
</div>
<hr/>
<div class="row">
<div class="col-lg-12">
</div>
<div class="row justify-content-center" id="dashboard">
<th:block th:each="conference : ${conferences}">
<div th:replace="conferences/fragments/confDashboardFragment :: confDashboard(conference=${conference})"/>
</th:block>
</div>
</div>
</section>

View File

@ -10,8 +10,14 @@
</div>
<div class="col col-10 text-right">
<h7 class="service-heading"> title</h7>
<p class="text-muted"></p>
<p th:if="${conference.url!=null and conference.url!=''}"><a target="_blank" th:href="${conference.url}"><i
class="fa fa-external-link fa-1x"
aria-hidden="true"></i></a></p>
<p th:unless="${conference.url!=null and conference.url!=''}"><i class="fa fa-fw fa-2x"
aria-hidden="true"></i></p>
<a th:href="'conference?id='+${conference.id}">
<h7 class="service-heading" th:text="${conference.title}"> title</h7>
</a>
</div>
</div>
</div>

View File

@ -13,7 +13,7 @@
</div>
<div class="col-12 col-sm-12 col-md-12 col-lg-4 col-xl-3">
<a href="./actual" class="btn btn-light toolbar-button">
<a href="./dashboard" class="btn btn-light toolbar-button">
<i class="fa fa-newspaper-o" aria-hidden="true"></i>
Актуальное</a>
</div>