This commit is contained in:
Your Name
2025-05-22 16:28:16 +02:00
parent 8d1fd7ba63
commit 4fc06ccce0
2 changed files with 101 additions and 3 deletions

View File

@@ -55,9 +55,46 @@
<p>Votre capteur est équipé d'un écran LED.</p>
<div class="row mb-3">
<div class="col-lg-3 col-12">
<form>
<div class="form-check mb-3">
<input class="form-check-input" type="checkbox" value="" id="matrix_display" onchange="update_config_sqlite('matrix_display_bool', this.checked)">
<label class="form-check-label" for="check_display">
Display
</label>
</div>
<select id="matrix_display_type" class="form-select" aria-label="Default select example" onchange="update_config_sqlite('matrix_display_type', this.value)">
<option value="display_WIFI_4G">Display internet and 4G conn.</option>
<option value="display_poll">Display compounds</option>
<option value="Display_3">Display 3</option>
</select>
</form>
</div>
</div>
<!-- toast -->
<div class="toast-container position-fixed bottom-0 end-0 p-3">
<div id="liveToast" class="toast align-items-center text-bg-primary border-1" role="alert" aria-live="assertive" aria-atomic="true">
<div class="d-flex">
<div class="toast-body">
Hello, world! This is a toast message.
</div>
<button type="button" class="btn-close btn-close-white me-2 m-auto" data-bs-dismiss="toast" aria-label="Close"></button>
</div>
</div>
</div>
</main>
@@ -113,6 +150,14 @@ $.ajax({
element.innerText = response.deviceName;
});
//matrix display
const checkbox_display = document.getElementById("matrix_display");
checkbox_display.checked = response.matrix_display_bool;
//matrix display type
const select_display_type = document.getElementById("matrix_display_type");
select_display_type.value = response.matrix_display_type;
},
error: function(xhr, status, error) {
console.error('AJAX request failed:', status, error);
@@ -136,8 +181,60 @@ $.ajax({
});
}//end windows on load
function update_config_sqlite(param, value){
console.log("Updating sqlite ",param," : ", value);
const toastLiveExample = document.getElementById('liveToast')
const toastBody = toastLiveExample.querySelector('.toast-body');
$.ajax({
url: 'launcher.php?type=update_config_sqlite&param='+param+'&value='+value,
dataType: 'json', // Specify that you expect a JSON response
method: 'GET', // Use GET or POST depending on your needs
cache: false, // Prevent AJAX from caching
success: function(response) {
console.log(response);
// Format the response nicely
let formattedMessage = '';
if (response.success) {
// Success message
toastLiveExample.classList.remove('text-bg-danger');
toastLiveExample.classList.add('text-bg-success');
formattedMessage = `
<strong>Success!</strong><br>
Parameter: ${response.param || param}<br>
Value: ${response.value || checked}<br>
${response.message || ''}
`;
} else {
// Error message
toastLiveExample.classList.remove('text-bg-success');
toastLiveExample.classList.add('text-bg-danger');
formattedMessage = `
<strong>Error!</strong><br>
${response.error || 'Unknown error'}<br>
Parameter: ${response.param || param}
`;
}
// Update the toast body with formatted content
toastBody.innerHTML = formattedMessage;
// Show the toast
const toastBootstrap = bootstrap.Toast.getOrCreateInstance(toastLiveExample)
toastBootstrap.show()
},
error: function(xhr, status, error) {
console.error('AJAX request failed:', status, error);
}
});
}
</script>
</body>

View File

@@ -88,7 +88,8 @@ config_entries = [
("windMeter", "0", "bool"),
("modem_version", "XXX", "str"),
# Add new config entries here
("matrix_display", "enabled", "str"),
("matrix_display", "0", "bool"),
("matrix_display_bool", "0", "bool"),
("matrix_display_type", "split_reveal", "str"),
("matrix_brightness", "100", "int")
]