diff --git a/html/sensors.html b/html/sensors.html index b2ff69b..7ccd120 100755 --- a/html/sensors.html +++ b/html/sensors.html @@ -273,6 +273,8 @@ function getBME280_values(){ window.onload = function() { //NEW way to get config (SQLite) + let mainConfig = {}; // Store main config for use in sensor card creation + $.ajax({ url: 'launcher.php?type=get_config_sqlite', dataType:'json', @@ -282,33 +284,32 @@ $.ajax({ console.log("Getting SQLite config table:"); console.log(response); - + mainConfig = response; // Store for later use + //device name_side bar const elements = document.querySelectorAll('.sideBar_sensorName'); elements.forEach((element) => { element.innerText = response.deviceName; }); + // After getting main config, create sensor cards + createSensorCards(mainConfig); + }, error: function(xhr, status, error) { console.error('AJAX request failed:', status, error); } });//end AJAX - //getting config_scripts table - $.ajax({ - url: 'launcher.php?type=get_config_scripts_sqlite', - dataType:'json', - //dataType: 'json', // Specify that you expect a JSON response - method: 'GET', // Use GET or POST depending on your needs - success: function(response) { - console.log("Getting SQLite config scripts table:"); - console.log(response); + //Function to create sensor cards based on config + function createSensorCards(config) { + console.log("Creating sensor cards with config:"); + console.log(config); const container = document.getElementById('card-container'); // Conteneur des cartes //creates NPM card (by default) - + const cardHTML = `