Automation Toggle

This commit is contained in:
JonatanRek 2019-10-11 17:35:06 +02:00
parent 6bad86b649
commit 6483567b20
2 changed files with 9 additions and 5 deletions

View File

@ -1,5 +1,6 @@
function restartAutomation(automationId){ function restartAutomation(automationId){
console.log("restartingAutomation" + automationId); console.log("restartingAutomation" + automationId);
event.preventDefault();
$.ajax({ $.ajax({
url: 'ajax', url: 'ajax',
type: 'POST', type: 'POST',
@ -16,8 +17,9 @@ function restartAutomation(automationId){
}); });
} }
function toggleAutomation(automationId){ function toggleAutomation(thisElement, automationId){
console.log("togglingAutomation" + automationId); console.log("togglingAutomation" + automationId);
event.preventDefault();
$.ajax({ $.ajax({
url: 'ajax', url: 'ajax',
type: 'POST', type: 'POST',
@ -26,7 +28,9 @@ function toggleAutomation(automationId){
"action": 'deactive' "action": 'deactive'
}, },
success: function(data){ success: function(data){
console.log(data); console.log($('automation-'+automationId));
$('#automation-'+automationId).toggleClass("is-inactive");
console.log('active');
}, },
error: function (request, status, error) { error: function (request, status, error) {
console.log("ERROR ", request, error); console.log("ERROR ", request, error);

View File

@ -1,6 +1,6 @@
<div class="col-12 col-md-6 col-xl-4 square-wrap"> <div class="col-12 col-md-6 col-xl-4 square-wrap">
<div class="rectangle-2"> <div class="rectangle-2">
<div class="square-content double <?php echo ($AUTOMATIONDATA['active'] == 0 ? 'paused' : ''); ?>" id="automation-<?php echo $AUTOMATIONID; ?>"> <div class="square-content double <?php echo ($AUTOMATIONDATA['active'] == 0 ? 'is-inactive' : ''); ?>" id="automation-<?php echo $AUTOMATIONID; ?>">
<div class="row"> <div class="row">
<div class="col-1"> <div class="col-1">
<h5 class="fa"> <h5 class="fa">
@ -53,10 +53,10 @@
</div> </div>
<div class="row"> <div class="row">
<div class="col"> <div class="col">
<a class="button is-primary m-1" onclick="$('#modal').removeClass('modal-container-hiden').show();"><?php $LANGMNG->echo('b_restart')?></a> <a class="button is-primary m-1" onClick="restartAutomation(this, <?php echo $AUTOMATIONID; ?>);"><?php $LANGMNG->echo('b_restart')?></a>
</div> </div>
<div class="col"> <div class="col">
<a class="button is-primary m-1" onclick="$('#modal').removeClass('modal-container-hiden').show();"><?php $LANGMNG->echo('b_disable')?></a> <a class="button is-primary m-1" onClick="toggleAutomation(this, <?php echo $AUTOMATIONID; ?>);"><?php $LANGMNG->echo('b_disable')?></a>
</div> </div>
</div> </div>
</div> </div>