show events

This commit is contained in:
Anton Romanov 2018-11-17 11:56:52 +04:00
parent c774820d95
commit 2d78753b06
5 changed files with 44 additions and 81 deletions

View File

@ -34,6 +34,11 @@ public class EventController {
return new Response<>(eventService.findAllDto()); return new Response<>(eventService.findAllDto());
} }
@GetMapping("/future")
public Response<List<EventDto>> getFutureEvents() {
return new Response<>(eventService.findAllFutureDto());
}
@PostMapping @PostMapping
public Response createEvent(@RequestBody @Valid EventDto timelineDto) { public Response createEvent(@RequestBody @Valid EventDto timelineDto) {
return new Response(eventService.create(timelineDto)); return new Response(eventService.create(timelineDto));

View File

@ -10,6 +10,6 @@ public interface EventRepository extends JpaRepository<Event, Integer> {
@Query("SELECT e FROM Event e WHERE e.executeDate = CURRENT_DATE") @Query("SELECT e FROM Event e WHERE e.executeDate = CURRENT_DATE")
List<Event> findByCurrentDate(); List<Event> findByCurrentDate();
@Query("SELECT e FROM Event e WHERE e.executeDate > CURRENT_DATE") @Query("SELECT e FROM Event e WHERE e.executeDate > CURRENT_DATE ORDER BY e.executeDate")
List<Event> findAllFuture(); List<Event> findAllFuture();
} }

View File

@ -90,4 +90,8 @@ public class EventService {
public List<Event> findAllFuture() { public List<Event> findAllFuture() {
return eventRepository.findAllFuture(); return eventRepository.findAllFuture();
} }
public List<EventDto> findAllFutureDto() {
return convert(findAllFuture(), EventDto::new);
}
} }

View File

@ -0,0 +1,27 @@
var urlTimeline = "/api/1.0/events/future";
function showTimeline(timelineElement) {
$(timelineElement).empty();
getFromRest(urlTimeline, function (eventList) {
eventList.forEach(function (event, index) {
var date = new Date(event.executeDate);
var formated_date = date.toLocaleDateString();
$(timelineElement).append("<li class='" + eventInverted(index) + "'>" +
"<div class=\"timeline-image\"><h4><br/>" + formated_date + "</h4></div>" +
"<div class=\"timeline-panel\">" +
"<div class=\"timeline-heading\">" +
"<h4>" + event.title + "</h4>" +
"</div>" +
"<div class=\"timeline-body\">" +
"<p class=\"text-muted\">" + event.description + "</p>" +
"</div>" +
"</div>" +
"</li>");
});
});
}
function eventInverted(index) {
return index % 2 == 1 ? "timeline-inverted" : "";
}

View File

@ -17,94 +17,21 @@
<div class="row"> <div class="row">
<div class="col-lg-12"> <div class="col-lg-12">
<ul class="timeline"> <ul class="timeline">
<li>
<div class="timeline-image">
<h4>
<br/>
02.07.2018
</h4>
</div>
<div class="timeline-panel">
<div class="timeline-heading">
<h4>Уход в отпуск</h4>
</div>
<div class="timeline-body">
<p class="text-muted">Наконец-то!</p>
</div>
</div>
</li>
<li class="timeline-inverted">
<div class="timeline-image">
<img class="rounded-circle img-fluid" src="img/about/2.jpg" alt=""/>
</div>
<div class="timeline-panel">
<div class="timeline-heading">
<h4>March 2011</h4>
<h4 class="subheading">An Agency is Born</h4>
</div>
<div class="timeline-body">
<p class="text-muted">Lorem ipsum dolor sit amet, consectetur adipisicing elit. Sunt
ut
voluptatum eius sapiente, totam reiciendis temporibus qui quibusdam, recusandae
sit
vero unde, sed, incidunt et ea quo dolore laudantium consectetur!</p>
</div>
</div>
</li>
<li>
<div class="timeline-image">
<img class="rounded-circle img-fluid" src="img/about/3.jpg" alt=""/>
</div>
<div class="timeline-panel">
<div class="timeline-heading">
<h4>December 2012</h4>
<h4 class="subheading">Transition to Full Service</h4>
</div>
<div class="timeline-body">
<p class="text-muted">Lorem ipsum dolor sit amet, consectetur adipisicing elit. Sunt
ut
voluptatum eius sapiente, totam reiciendis temporibus qui quibusdam, recusandae
sit
vero unde, sed, incidunt et ea quo dolore laudantium consectetur!</p>
</div>
</div>
</li>
<li class="timeline-inverted">
<div class="timeline-image">
<img class="rounded-circle img-fluid" src="img/about/4.jpg" alt=""/>
</div>
<div class="timeline-panel">
<div class="timeline-heading">
<h4>July 2014</h4>
<h4 class="subheading">Phase Two Expansion</h4>
</div>
<div class="timeline-body">
<p class="text-muted">Lorem ipsum dolor sit amet, consectetur adipisicing elit. Sunt
ut
voluptatum eius sapiente, totam reiciendis temporibus qui quibusdam, recusandae
sit
vero unde, sed, incidunt et ea quo dolore laudantium consectetur!</p>
</div>
</div>
</li>
<li class="timeline-inverted">
<div class="timeline-image">
<h4>Be Part
<br/>Of Our
<br/>Story!</h4>
</div>
</li>
</ul> </ul>
</div> </div>
</div> </div>
</div> </div>
</section> </section>
<!-- Plugin JavaScript -->
<script src="vendor/jquery-easing/jquery.easing.min.js"></script>
<!-- Custom scripts for this template --> <!-- Custom scripts for this template -->
<script src="js/agency.js"></script> <script src="js/agency.js"></script>
<script src="js/timeline.js"></script>
<script>
$(document).ready(function() {
showTimeline(".timeline")
})
</script>
</div> </div>
</body> </body>