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 () { public function getUsers () {
try { 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; return $allUsers;
} catch(PDOException $error) { } catch(PDOException $error) {
echo $error->getMessage(); echo $error->getMessage();

View File

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