Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Added a countdown on the home page

  • Loading branch information...
commit f241a16f9c4cfad78c67e626e8a8fe35b21f939b 1 parent cda8dea
@fboulay authored
Showing with 45 additions and 19 deletions.
  1. +4 −1 app/controllers/Home.java
  2. +41 −18 app/views/Home/index.html
View
5 app/controllers/Home.java
@@ -1,9 +1,11 @@
package controllers;
+import java.util.Date;
import java.util.List;
import models.Person;
import models.PersonAndTimeSlot;
+import org.joda.time.DateMidnight;
import play.mvc.Controller;
import play.mvc.With;
@@ -13,7 +15,8 @@
public static void index() {
List<Person> freePersons = Person.getAllPerson(PersonAndTimeSlot.TimeSlotStatus.AVAILABLE);
List<Person> onCallPersons = Person.getAllPerson(PersonAndTimeSlot.TimeSlotStatus.ON_CALL);
- render(freePersons, onCallPersons);
+ long timeToNextChange = (new DateMidnight().plusDays(1).toDate().getTime() - new Date().getTime()) / 1000;
+ render(freePersons, onCallPersons, timeToNextChange);
}
public static void deletePerson(long id) {
View
59 app/views/Home/index.html
@@ -1,21 +1,44 @@
#{extends 'main.html' /}
#{set title:'Home page - Summary' /}
+#{set 'moreScripts'}
+<script src="@{'/public/javascripts/countdown.js'}" type="text/javascript" charset="utf-8"></script>
+#{/set}
+#{set 'moreStyles'}
+<link rel="stylesheet" type="text/css" media="screen" href="@{'/public/stylesheets/home.css'}"/>
+#{/set}
-
-#{if freePersons}
-<h1><span>List of currently free employees</span></h1>
-<ul>
- #{list freePersons}
- <li>${_.firstName} ${_.lastName}</li>
- #{/list}
-</ul>
-#{/if}
-
-#{if onCallPersons}
-<h1><span>List of currently on call employees</span></h1>
-<ul>
- #{list onCallPersons}
- <li>${_.firstName} ${_.lastName}</li>
- #{/list}
-</ul>
-#{/if}
+<table class="home-table">
+ <tbody>
+ <tr>
+ <td>
+ #{if freePersons}
+ <h1><span>List of currently free employees</span></h1>
+ <ul>
+ #{list freePersons}
+ <li>${_.firstName} ${_.lastName}</li>
+ #{/list}
+ </ul>
+ #{/if}
+ </td>
+ <td rowspan="2">
+ <div style="text-align:right">Next change in</div>
+ <div id="countdown_time"></div>
+ <script type="text/javascript">
+ jsCountdown.init(${timeToNextChange}, 'countdown_time');
+ </script>
+ </td>
+ </tr>
+ <tr>
+ <td>
+ #{if onCallPersons}
+ <h1><span>List of currently on call employees</span></h1>
+ <ul>
+ #{list onCallPersons}
+ <li>${_.firstName} ${_.lastName}</li>
+ #{/list}
+ </ul>
+ #{/if}
+ </td>
+ </tr>
+ </tbody>
+</table>
Please sign in to comment.
Something went wrong with that request. Please try again.