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){
console.log("restartingAutomation" + automationId);
event.preventDefault();
$.ajax({
url: 'ajax',
type: 'POST',
@ -16,8 +17,9 @@ function restartAutomation(automationId){
});
}
function toggleAutomation(automationId){
function toggleAutomation(thisElement, automationId){
console.log("togglingAutomation" + automationId);
event.preventDefault();
$.ajax({
url: 'ajax',
type: 'POST',
@ -26,7 +28,9 @@ function toggleAutomation(automationId){
"action": 'deactive'
},
success: function(data){
console.log(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

@ -1,6 +1,6 @@
<div class="col-12 col-md-6 col-xl-4 square-wrap">
<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="col-1">
<h5 class="fa">
@ -53,10 +53,10 @@
</div>
<div class="row">
<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 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>