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

View File

@ -53,10 +53,10 @@
</div>
<div class="row">
<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 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>