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 = new Partial('footer');
$partial->render(); $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> </body>
</html> </html>

View File

@ -5,6 +5,7 @@ function ajaxPostSimple(path, params, reload = false) {
type: 'POST', type: 'POST',
data: params, data: params,
success: function(msg){ success: function(msg){
console.log("message");
console.log(msg); console.log(msg);
if (reload){ if (reload){
location.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> <h5 unselectable="on" class="fa">&#x<?php echo $DEVICE['icon'] ?></h5>
</div> </div>
<div class="col"> <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> <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> </div>
<div class="row"> <div class="row">

View File

@ -84,6 +84,14 @@ class Ajax extends Template
die(); die();
break; 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: default:
echo 'no action detected'; echo 'no action detected';
break; break;
@ -125,7 +133,6 @@ class Ajax extends Template
break; break;
case 'sendTest': case 'sendTest':
echo "test";
$notificationData = [ $notificationData = [
'title' => 'Alert', 'title' => 'Alert',
'body' => 'test notification', 'body' => 'test notification',