OTA PART 2 Setting Page

This commit is contained in:
JonatanRek 2019-10-25 18:48:48 +02:00
parent 66b433950b
commit 1e464e6e53
3 changed files with 31 additions and 10 deletions

View File

@ -3,7 +3,7 @@ class UserManager
{
public function getUsers () {
try {
$allUsers = Db::loadAll ("SELECT user_id, username, at_home FROM users");
$allUsers = Db::loadAll ("SELECT user_id, username, at_home, ota FROM users");
return $allUsers;
} catch(PDOException $error) {
echo $error->getMessage();

View File

@ -37,4 +37,22 @@ function sendTestNotification(){
console.log("ERROR ", request, error);
}
});
}
}
$( "button[name='deactivateOta']" ).click(function(){
console.log("Didabling ota");
$.ajax({
url: 'ajax',
type: 'POST',
data: {
"ota" : 'X',
"action": 'disable'
},
success: function(data){
console.log(data);
},
error: function (request, status, error) {
console.log("ERROR ", request, error);
}
});
})

View File

@ -77,11 +77,12 @@
</form>
</div>
<div class="col-12 col-sm-9 mx-auto mt-4">
<h4 class="mb-4"><?php ?></h4>
<img src="<?php echo $QRURL;?>" />
<form method="post">
</form>
<h4 class="mb-4"><?php $LANGMNG->echo('t_ota') ?></h4>
<?php if (!empty($QRURL)) {?>
<img src="<?php echo $QRURL;?>" />
<?php } else {?>
<button name="deactivateOta" type="button" class="button is-danger fa"><?php $LANGMNG->echo('b_disable');?> <?php $LANGMNG->echo('b_ota'); ?></button>
<?php }?>
</div>
<div class="col-12 col-sm-9 mx-auto mt-4">
<h4 class="mb-4"><?php $LANGMNG->echo('t_createuser') ?></h4>
@ -89,6 +90,7 @@
<thead>
<tr>
<th><?php $LANGMNG->echo('t_userName');?></th>
<th><?php $LANGMNG->echo('t_ota');?></th>
<th><?php $LANGMNG->echo('t_action');?></th>
</tr>
</thead>
@ -96,6 +98,7 @@
<?php foreach ($USERS as $key => $user) { ?>
<tr>
<td><?php echo $user['username']; ?></td>
<td><?php echo ($user['ota'] ? '<span class="fa">&#xf00c;</span>' : ''); ?></td>
<td><button name="deleteUser" type="button" class="button is-danger fa">&#xf1f8;</button></td>
</tr>
<?php } ?>
@ -116,14 +119,14 @@
</form>
</div>
</div>
</div>
<script src="./app/templates/js/setting.js"></script>
<?php
$partial = new Partial('footer');
$partial->render();
?>
<script src="./app/templates/js/setting.js"></script>
</script>
</body>
</html>