This commit is contained in:
PaulVua
2025-01-23 18:03:11 +01:00
parent 660af80ab0
commit 155a2bd453
4 changed files with 74 additions and 11 deletions

View File

@@ -60,27 +60,37 @@
<form>
<div class="form-check form-switch mb-2">
<input class="form-check-input" type="checkbox" role="switch" id="flexSwitchCheckDefault">
<label class="form-check-label" for="flexSwitchCheckDefault">Loop Logs</label>
<input class="form-check-input" type="checkbox" role="switch" id="flex_loop" onchange="update_config(this.checked)">
<label class="form-check-label" for="flex_loop">Loop activation</label>
</div>
<div class="form-check form-switch mb-2">
<input class="form-check-input" type="checkbox" role="switch" id="flexSwitchCheckDefault">
<label class="form-check-label" for="flexSwitchCheckDefault">Boot Logs</label>
<input class="form-check-input" type="checkbox" role="switch" id="flex_loop_log">
<label class="form-check-label" for="flex_loop_log">Loop Logs</label>
</div>
<div class="form-check form-switch mb-2">
<input class="form-check-input" type="checkbox" role="switch" id="flex_start_log">
<label class="form-check-label" for="flex_start_log">Boot Logs</label>
</div>
<div class="form-check mb-3">
<input class="form-check-input" type="checkbox" value="" id="flexCheckDefault">
<label class="form-check-label" for="flexCheckDefault">
<input class="form-check-input" type="checkbox" value="" id="check_bme280s">
<label class="form-check-label" for="check_bme280">
Sonde temp/hum (BME280)
</label>
</div>
<div class="mb-3">
<label for="exampleInputEmail1" class="form-label">ssh tunnel port</label>
<input type="email" class="form-control" id="exampleInputEmail1" aria-describedby="emailHelp">
<label for="device_name" class="form-label">Device Name</label>
<input type="text" class="form-control" id="device_name">
</div>
<div class="mb-3">
<label for="exampleInputPassword1" class="form-label">Password</label>
<input type="password" class="form-control" id="exampleInputPassword1">
</div>
<label for="device_ID" class="form-label">Device ID</label>
<input type="text" class="form-control" id="device_ID" disabled>
</div>
<button type="submit" class="btn btn-primary">Submit</button>
</form>
</div>
@@ -142,6 +152,29 @@ window.onload = function() {
element.innerText = deviceName;
});
//get BME check
const checkbox = document.getElementById("check_bme280s");
checkbox.checked = data.i2c_BME;
//loop activation
const flex_loop = document.getElementById("flex_loop");
flex_loop.checked = data.loop_activation;
//loop logs
const flex_loop_log = document.getElementById("flex_loop_log");
flex_loop_log.checked = data.loop_log;
//start logs
const flex_start_log = document.getElementById("flex_start_log");
flex_start_log.checked = data.boot_log;
//device name
const device_name = document.getElementById("device_name");
device_name.value = data.deviceName;
//device ID
const device_ID = document.getElementById("device_ID");
device_ID.value = data.deviceID.toUpperCase();
//get local RTC
$.ajax({
@@ -163,6 +196,21 @@ window.onload = function() {
}
function update_config(isChecked){
console.log("Updated flex_loop:", isChecked);
$.ajax({
url: 'launcher.php?type=update_config',
dataType: 'text', // Specify that you expect a JSON response
method: 'GET', // Use GET or POST depending on your needs
success: function(response) {
console.log(response);
},
error: function(xhr, status, error) {
console.error('AJAX request failed:', status, error);
}
});
}
function updateGitPull(){
console.log("Updating device (git pull)");