diff --git a/html/admin.html b/html/admin.html index 2576300..ae5e3aa 100755 --- a/html/admin.html +++ b/html/admin.html @@ -110,6 +110,34 @@ .catch(error => console.error(`Error loading ${file}:`, error)); }); }); + +window.onload = function() { + fetch('../config.json') // Replace 'deviceID.txt' with 'config.json' + .then(response => response.json()) // Parse response as JSON + .then(data => { + console.log("Getting config file (onload)"); + //get device ID + const deviceID = data.deviceID.trim().toUpperCase(); + document.getElementById('pageTitle_plus_ID').innerText = 'token: ' + deviceID; + + //get local RTC + $.ajax({ + url: 'launcher.php?type=RTC_time', + dataType: 'text', // Specify that you expect a JSON response + method: 'GET', // Use GET or POST depending on your needs + success: function(response) { + console.log("Local RTC: " + response); + const RTC_Element = document.getElementById("RTC_time"); + RTC_Element.textContent = response; + }, + error: function(xhr, status, error) { + console.error('AJAX request failed:', status, error); + } + }); + + }) + .catch(error => console.error('Error loading config.json:', error)); + } diff --git a/html/index.html b/html/index.html index 916226e..a3a8ef4 100755 --- a/html/index.html +++ b/html/index.html @@ -50,8 +50,23 @@

Votre capteur

-

This is the main content area. You can add any content you want here.

-

Lorem ipsum dolor sit amet, consectetur adipiscing elit. Integer nec odio. Praesent libero. Sed cursus ante dapibus diam.

+

Bienvenue sur votre interface de configuration de votre capteur.

+
+ +
+
+ +
+
Linux stats
+ +

Disk space

+
+ +
+
+
+ +
@@ -83,6 +98,74 @@ .catch(error => console.error(`Error loading ${file}:`, error)); }); }); + +window.onload = function() { + fetch('../config.json') // Replace 'deviceID.txt' with 'config.json' + .then(response => response.json()) // Parse response as JSON + .then(data => { + console.log("Getting config file (onload)"); + //get device ID + const deviceID = data.deviceID.trim().toUpperCase(); + document.getElementById('pageTitle_plus_ID').innerText = 'token: ' + deviceID; + + //get local RTC + $.ajax({ + url: 'launcher.php?type=RTC_time', + dataType: 'text', // Specify that you expect a JSON response + method: 'GET', // Use GET or POST depending on your needs + success: function(response) { + console.log("Local RTC: " + response); + const RTC_Element = document.getElementById("RTC_time"); + RTC_Element.textContent = response; + }, + error: function(xhr, status, error) { + console.error('AJAX request failed:', status, error); + } + }); + + //get disk free space + $.ajax({ + url: 'launcher.php?type=linux_disk', + dataType: 'text', // Specify that you expect a JSON response + method: 'GET', // Use GET or POST depending on your needs + success: function(response) { + console.log("Linux disk space: " + response); + const match = response.match(/(\d+)%/); + + const diskSpace = document.getElementById("disk_space"); + const percentage = match[1]; + + // Create the outer div with class and attributes + const progressDiv = document.createElement('div'); + progressDiv.className = 'progress'; + progressDiv.setAttribute('role', 'progressbar'); + progressDiv.setAttribute('aria-label', 'Example with label'); + progressDiv.setAttribute('aria-valuenow', percentage); + progressDiv.setAttribute('aria-valuemin', 0); + progressDiv.setAttribute('aria-valuemax', 100); + + // Create the inner progress bar div + const progressBarDiv = document.createElement('div'); + progressBarDiv.className = 'progress-bar'; + progressBarDiv.style.width = `${percentage}%`; // Set the width dynamically + progressBarDiv.textContent = `${percentage}%`; // Set the text dynamically + + // Append the progress bar to the outer div + progressDiv.appendChild(progressBarDiv); + + // Append the entire progress bar to the body (or any other container) + diskSpace.appendChild(progressDiv); + + }, + error: function(xhr, status, error) { + console.error('AJAX request failed:', status, error); + } + }); + + }) + .catch(error => console.error('Error loading config.json:', error)); + } + diff --git a/html/launcher.php b/html/launcher.php index ea95e20..4697416 100755 --- a/html/launcher.php +++ b/html/launcher.php @@ -12,6 +12,12 @@ if ($type == "git_pull") { echo $output; } +if ($type == "linux_disk") { + $command = 'df -h /'; + $output = shell_exec($command); + echo $output; +} + if ($type == "sshTunnel") { $ssh_port=$_GET['ssh_port']; $command = 'sudo ssh -i /var/www/.ssh/id_rsa -f -N -R "'.$ssh_port.':localhost:22" -p 50221 -o StrictHostKeyChecking=no "airlab_server1@aircarto.fr"'; diff --git a/html/logs.html b/html/logs.html index fdc6ea2..69d6162 100755 --- a/html/logs.html +++ b/html/logs.html @@ -162,6 +162,35 @@ }); + + +window.onload = function() { + fetch('../config.json') // Replace 'deviceID.txt' with 'config.json' + .then(response => response.json()) // Parse response as JSON + .then(data => { + console.log("Getting config file (onload)"); + //get device ID + const deviceID = data.deviceID.trim().toUpperCase(); + document.getElementById('pageTitle_plus_ID').innerText = 'token: ' + deviceID; + + //get local RTC + $.ajax({ + url: 'launcher.php?type=RTC_time', + dataType: 'text', // Specify that you expect a JSON response + method: 'GET', // Use GET or POST depending on your needs + success: function(response) { + console.log("Local RTC: " + response); + const RTC_Element = document.getElementById("RTC_time"); + RTC_Element.textContent = response; + }, + error: function(xhr, status, error) { + console.error('AJAX request failed:', status, error); + } + }); + + }) + .catch(error => console.error('Error loading config.json:', error)); + } diff --git a/html/topbar.html b/html/topbar.html index d65a760..4c2d4ef 100755 --- a/html/topbar.html +++ b/html/topbar.html @@ -6,8 +6,11 @@
- - Texte au milieu + + + Texte au milieu + +
diff --git a/html/wifi.html b/html/wifi.html index d1c63d2..af1baaf 100755 --- a/html/wifi.html +++ b/html/wifi.html @@ -284,6 +284,51 @@ function get_internet(){ // You can display a simple confirmation message or customize the behavior return confirm("Are you sure you want to connect to this Wi-Fi network?"); } + + window.onload = function() { + fetch('../config.json') // Replace 'deviceID.txt' with 'config.json' + .then(response => response.json()) // Parse response as JSON + .then(data => { + console.log("Getting config file (onload)"); + //get device ID + const deviceID = data.deviceID.trim().toUpperCase(); + document.getElementById('pageTitle_plus_ID').innerText = 'token: ' + deviceID; + + //get wifi connection status + const WIFI_statusElement = document.getElementById("wifi-status"); + console.log("WIFI is: " + data.WIFI_status); + + if (data.WIFI_status === "connected") { + WIFI_statusElement.textContent = "Connected"; + WIFI_statusElement.className = "badge text-bg-success"; + } else if (data.WIFI_status === "hotspot") { + WIFI_statusElement.textContent = "Hotspot"; + WIFI_statusElement.className = "badge text-bg-warning"; + } else { + WIFI_statusElement.textContent = "Unknown"; + WIFI_statusElement.className = "badge text-bg-secondary"; + } + + //get local RTC + $.ajax({ + url: 'launcher.php?type=RTC_time', + dataType: 'text', // Specify that you expect a JSON response + method: 'GET', // Use GET or POST depending on your needs + success: function(response) { + console.log("Local RTC: " + response); + const RTC_Element = document.getElementById("RTC_time"); + RTC_Element.textContent = response; + }, + error: function(xhr, status, error) { + console.error('AJAX request failed:', status, error); + } + }); + + + }) + .catch(error => console.error('Error loading config.json:', error)); + } +