Added toggle witch to detail page

This commit is contained in:
Ziver Koc 2019-11-11 18:05:04 +01:00 committed by Ziver Koc
parent 9de2ee1e3c
commit 5d21a0cc05
3 changed files with 30 additions and 3 deletions

View file

@ -23,6 +23,21 @@
<th class="text-right">Owner:</th>
<td>{{event.getUser().getUsername()}} <p></td>
</tr>
<tr>
<th class="text-right">State:</th>
<td>
<form method="POST">
<input type="hidden" name="action" value="modify">
<input type="hidden" name="action_id" value="{{.getId()}}">
<div class="btn-toolbar pull-left">
<input class="toggle-switch" type="checkbox" name="enabled"
data-size="mini" data-on-color="danger"
{{event.getDeviceData().getData()}}checked{{/event.getDeviceData().getData()}} >
</div>
</form>
</td>
</tr>
{{#event.getDeviceConfigurator().getConfiguration()}}
<tr>
<th class="text-right">{{.getNiceName()}}:</th>
@ -54,3 +69,11 @@
</div>
</div>
</div>
<script>
$(function (){
$(".toggle-switch").on("switchChange.bootstrapSwitch", function (event, state) {
$(this).closest('form').submit();
});
});
</script>

View file

@ -22,7 +22,7 @@
<td>
<form method="POST">
<input type="hidden" name="action" value="modify">
<input type="hidden" name="id" value="{{.getId()}}">
<input type="hidden" name="action_id" value="{{.getId()}}">
<div class="btn-toolbar pull-right">
<input class="toggle-switch" type="checkbox" name="enabled"