From 4fc06ccce08948c02b3c9fa929900212ba0a2ea8 Mon Sep 17 00:00:00 2001 From: Your Name Date: Thu, 22 May 2025 16:28:16 +0200 Subject: [PATCH] update --- html/matrix_led.html | 101 ++++++++++++++++++++++++++++++++++++- sqlite/set_config_smart.py | 3 +- 2 files changed, 101 insertions(+), 3 deletions(-) diff --git a/html/matrix_led.html b/html/matrix_led.html index 4862d24..15f0159 100644 --- a/html/matrix_led.html +++ b/html/matrix_led.html @@ -55,10 +55,47 @@

Votre capteur est équipé d'un écran LED.

+
+ +
-
+ + +
+ + +
+ + + + +
+ + + + + + + + +
+ +
@@ -112,6 +149,14 @@ $.ajax({ elements.forEach((element) => { 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) { @@ -136,7 +181,59 @@ $.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¶m='+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 = ` + Success!
+ Parameter: ${response.param || param}
+ Value: ${response.value || checked}
+ ${response.message || ''} + `; + } else { + // Error message + toastLiveExample.classList.remove('text-bg-success'); + toastLiveExample.classList.add('text-bg-danger'); + + formattedMessage = ` + Error!
+ ${response.error || 'Unknown error'}
+ 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); + } + }); +} + diff --git a/sqlite/set_config_smart.py b/sqlite/set_config_smart.py index cd874ca..505f2f4 100644 --- a/sqlite/set_config_smart.py +++ b/sqlite/set_config_smart.py @@ -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") ]