Termostatic radiator head Preparation #Feature

This commit is contained in:
JonatanRek 2020-03-30 08:56:06 +02:00
parent 0593bf09dd
commit e22d98cf6a
4 changed files with 186 additions and 150 deletions

View File

@ -85,5 +85,23 @@
$partial = new Partial('footer');
$partial->render();
?>
<script>
$(document).on('keyup mouseup', '#value_control', function(event) {
$.ajax({
url: 'ajax',
type: 'POST',
//TODO: GET Attribute from ID
data: { subDevice_id : '46', action : 'set', value: this.value},
success: function(msg){
console.log("message");
console.log(msg);
},
error: function (request, status, error) {
console.log('0');
}
});
console.log(this.value);
});
</script>
</body>
</html>

View File

@ -5,6 +5,7 @@ function ajaxPostSimple(path, params, reload = false) {
type: 'POST',
data: params,
success: function(msg){
console.log("message");
console.log(msg);
if (reload){
location.reload();

View File

@ -15,7 +15,17 @@ if ($SUBDEVICE['type'] == 'on/off') {
<h5 unselectable="on" class="fa">&#x<?php echo $DEVICE['icon'] ?></h5>
</div>
<div class="col">
<?php if ($SUBDEVICE['type'] == 'temp_cont') { ?>
<input type="number" step="5" class="device-button-value text-right" id="value_control" value="<?php echo $SUBDEVICE['lastRecort']['value'] ?>"><?php echo $SUBDEVICE['unit']?>
<style>
input.device-button-value.text-right {
width: inherit;
}
</style>
<?php } else { ?>
<h5 unselectable="on" class="device-button-value text-right" title="<?php echo $SUBDEVICE['lastRecort']['time']; ?>"><?php echo $SUBDEVICE['lastRecort']['value'] . $SUBDEVICE['unit']?></h5>
<?php } ?>
</div>
</div>
<div class="row">

View File

@ -84,6 +84,14 @@ class Ajax extends Template
die();
break;
case 'set':
$value = $_POST['value'];
$subDevice = SubDeviceManager::getSubDevice($subDeviceId);
RecordManager::create($subDevice['device_id'], $subDevice['type'], $value);
echo 'test id' . $subDevice['device_id'] .$subDevice['type'] . $value ;
die();
break;
default:
echo 'no action detected';
break;
@ -125,7 +133,6 @@ class Ajax extends Template
break;
case 'sendTest':
echo "test";
$notificationData = [
'title' => 'Alert',
'body' => 'test notification',