Automation Toggle #2

This commit is contained in:
JonatanRek 2019-10-11 17:41:58 +02:00
parent 6483567b20
commit b0985b8ea2
2 changed files with 5 additions and 9 deletions

View File

@ -1,12 +1,11 @@
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',
data: { data: {
"automation_id" : automationId, "automation_id" : automationId,
"action": 'restart' "action": "restart"
}, },
success: function(data){ success: function(data){
console.log(data); console.log(data);
@ -17,20 +16,17 @@ function restartAutomation(automationId){
}); });
} }
function toggleAutomation(thisElement, automationId){ function toggleAutomation(automationId){
console.log("togglingAutomation" + automationId); console.log("togglingAutomation" + automationId);
event.preventDefault();
$.ajax({ $.ajax({
url: 'ajax', url: 'ajax',
type: 'POST', type: 'POST',
data: { data: {
"automation_id" : automationId, "automation_id" : automationId,
"action": 'deactive' "action": "deactive"
}, },
success: function(data){ success: function(data){
console.log($('automation-'+automationId));
$('#automation-'+automationId).toggleClass("is-inactive"); $('#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

@ -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="restartAutomation(this, <?php echo $AUTOMATIONID; ?>);"><?php $LANGMNG->echo('b_restart')?></a> <a class="button is-primary m-1" onClick="restartAutomation(<?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="toggleAutomation(this, <?php echo $AUTOMATIONID; ?>);"><?php $LANGMNG->echo('b_disable')?></a> <a class="button is-primary m-1" onClick="toggleAutomation(<?php echo $AUTOMATIONID; ?>);"><?php $LANGMNG->echo('b_disable')?></a>
</div> </div>
</div> </div>
</div> </div>