#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())); conferenceFilterDto.getYear()));
} }
@GetMapping("/dashboard")
public void getDashboard(ModelMap modelMap) {
modelMap.put("conferences", conferenceService.findAllActiveDto());
}
@GetMapping("/conference") @GetMapping("/conference")
public void getConference(ModelMap modelMap, @RequestParam(value = "id") Integer id) { public void getConference(ModelMap modelMap, @RequestParam(value = "id") Integer id) {
if (id != null && id > 0) { 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.conference.model.Conference;
import ru.ulstu.user.model.User; import ru.ulstu.user.model.User;
import java.util.Date;
import java.util.List; import java.util.List;
public interface ConferenceRepository extends JpaRepository<Conference, Integer> { 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) " + @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") "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); 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.io.IOException;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Arrays; import java.util.Arrays;
import java.util.Date;
import java.util.List; import java.util.List;
import static org.springframework.util.ObjectUtils.isEmpty; import static org.springframework.util.ObjectUtils.isEmpty;
@ -164,4 +165,12 @@ public class ConferenceService {
conferenceFilterDto.getYear()), ConferenceDto::new); 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"> <div class="form-group">
<label for="url">URL:</label> <label for="url">URL:</label>
<input class="form-control" th:field="*{url}" id="url" type="text" <input class="form-control" th:field="*{url}" id="url" type="text"
placeholder="URL адрес"/> placeholder="http://"/>
</div> </div>
<div class="form-group"> <div class="form-group">

View File

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

View File

@ -10,8 +10,14 @@
</div> </div>
<div class="col col-10 text-right"> <div class="col col-10 text-right">
<h7 class="service-heading"> title</h7> <p th:if="${conference.url!=null and conference.url!=''}"><a target="_blank" th:href="${conference.url}"><i
<p class="text-muted"></p> 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> </div>
</div> </div>

View File

@ -13,7 +13,7 @@
</div> </div>
<div class="col-12 col-sm-12 col-md-12 col-lg-4 col-xl-3"> <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> <i class="fa fa-newspaper-o" aria-hidden="true"></i>
Актуальное</a> Актуальное</a>
</div> </div>