Commit ee4f1db3 authored by Jan Wagemakers's avatar Jan Wagemakers

possible to edit users and rules now

parent c39144ca
......@@ -102,6 +102,7 @@ public class HTMLController {
public String user(@ModelAttribute User newUser, @RequestParam String action, @RequestParam String id, Model model ) {
switch (action) {
case "Add" :
case "Save" :
newUser = userRepository.save(newUser);
break;
case "Del" :
......@@ -122,10 +123,14 @@ public class HTMLController {
@PostMapping("/rule")
public String rule(@ModelAttribute Rule newRule, @RequestParam String action, @RequestParam String line, Model model ) {
if (action.equals("ADD")) {
switch (action) {
case "Add" :
case "Save" :
newRule = ruleRepository.save(newRule);
} else {
break;
case "Del" :
ruleRepository.deleteById(Integer.parseInt(line));
break;
}
return rules(model);
}
......
......@@ -34,14 +34,13 @@
</header>
<section class="post-content">
<div id="refresh">
<h2 th:text="'Rules : ' + ${user}"></h2>
<hr>
<form th:each="rule : ${rules}" action="#" th:action="@{/rule}" method="post">
<input type="hidden" name="line" th:value="${rule.line}" readonly />
<input type="hidden" name="line" th:value="${rule.line}" readonly/>
<p>
<select disabled >
<select name="day">
<option th:value="0" th:selected="${0==rule.day}" th:text="'Every Day'"></option>
<option th:value="1" th:selected="${1==rule.day}" th:text="Sunday"></option>
<option th:value="2" th:selected="${2==rule.day}" th:text="Monday"></option>
......@@ -51,18 +50,21 @@
<option th:value="6" th:selected="${6==rule.day}" th:text="Friday"></option>
<option th:value="7" th:selected="${7==rule.day}" th:text="Saturday"></option>
</select>
<input type="hidden" name="day" th:value="${rule.day}" readonly />
<!-- <input type="hidden" name="day" th:value="${rule.day}" > -->
</p>
<p>
<input style="width: 10%" type="number" min="0" max="23" name="hour" th:value="${rule.hour}" readonly />
<input style="width: 10%" type="number" min="0" max="23" name="hour" th:value="${rule.hour}">
h&nbsp;:&nbsp;
<input style="width: 10%" type="number" min="0" max="59" name="min" th:value="${rule.min}" readonly />
<input style="width: 10%" type="number" min="0" max="59" name="min" th:value="${rule.min}">
m&nbsp;=&nbsp;
<input style="width: 10%" type="number" min="0" max="30" step="0.1" name="temp" th:value="${rule.temp}" readonly />
<input style="width: 10%" type="number" min="0" max="30" step="0.1" name="temp" th:value="${rule.temp}">
°C
</p>
<p><input type="hidden" name="userId" th:value="${rule.user.id}" readonly /></p>
<p><input type="submit" name="action" value="DEL" /></p>
<p><input type="hidden" name="user" th:value="${rule.user.id}" readonly/></p>
<p>
<input type="submit" name="action" value="Save"/>
<input type="submit" name="action" value="Del"/>
</p>
<hr>
</form>
<h2>Add a new rule</h2>
......@@ -91,26 +93,13 @@
°C
</p>
<p><input type="hidden" th:field="*{user.id}" readonly/></p>
<p><input type="submit" name="action" value="ADD"/></p>
<p><input type="submit" name="action" value="Add"/></p>
</form>
<hr>
</div>
</section>
</article>
</div>
<!--
<script type="text/javascript"
src="http://code.jquery.com/jquery-1.10.1.min.js">
</script>
<script>
$(document).ready(
function() {
setInterval(function() {
$('#refresh').load('./rules #refresh');
}, 1000);
});
</script>
-->
</body>
</html>
......@@ -34,20 +34,19 @@
</header>
<section class="post-content">
<div id="refresh">
<h2>Current users</h2>
<hr>
<form th:each="user : ${users}" action="#" th:action="@{/users}" method="post">
<input type="hidden" name="id" th:value="${user.id}" readonly/>
Name:<br>
<p><input type="text" name="name" th:value="${user.name}" readonly/></p>
<p><input type="text" name="name" th:value="${user.name}" ></p>
Smartphone&apos;s bluetooth:<br>
<p><input type="text" name="bluetooth" th:value="${user.bluetooth}" readonly/></p>
<p><input type="text" name="bluetooth" th:value="${user.bluetooth}" ></p>
<input type="submit" name="action" value="Save"/>
<input type="submit" name="action" value="Del"/>
<input type="submit" name="action" value="Rules"/>
<hr>
</form>
</div>
<h2>Add a new user</h2>
<hr>
<form action="#" th:action="@{/users}" th:object="${newUser}" method="post">
......@@ -63,17 +62,5 @@
</article>
</div>
<script type="text/javascript"
src="http://code.jquery.com/jquery-1.10.1.min.js">
</script>
<script>
$(document).ready(
function() {
setInterval(function() {
$('#refresh').load('./users #refresh');
}, 1000);
});
</script>
</body>
</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