This commit is contained in:
PaulVua
2025-01-20 13:21:54 +01:00
parent 4d45e34a21
commit 8ebf8dac51
9 changed files with 91 additions and 7 deletions

View File

@@ -2,6 +2,7 @@
"loop_log": true, "loop_log": true,
"boot_log": true, "boot_log": true,
"deviceID": "XXXX", "deviceID": "XXXX",
"deviceName": "NebuleAir-proXXX",
"SaraR4_baudrate": 115200, "SaraR4_baudrate": 115200,
"NextPM_ports": [ "NextPM_ports": [
"ttyAMA5" "ttyAMA5"

View File

@@ -39,12 +39,12 @@
<button type="button" class="btn-close btn-close-white" data-bs-dismiss="offcanvas" aria-label="Close"></button> <button type="button" class="btn-close btn-close-white" data-bs-dismiss="offcanvas" aria-label="Close"></button>
</div> </div>
<div class="offcanvas-body" id="sidebar_mobile"> <div class="offcanvas-body" id="sidebar_mobile">
</div> </div>
</div> </div>
<div class="container-fluid mt-5"> <div class="container-fluid mt-5">
<div class="row"> <div class="row">
<!-- Side bar -->
<aside class="col-md-2 col-lg-1 d-none d-md-block vh-100 position-fixed bg-dark text-white" id="sidebar"> <aside class="col-md-2 col-lg-1 d-none d-md-block vh-100 position-fixed bg-dark text-white" id="sidebar">
</aside> </aside>
<!-- Main content --> <!-- Main content -->
@@ -133,7 +133,15 @@ window.onload = function() {
console.log("Getting config file (onload)"); console.log("Getting config file (onload)");
//get device ID //get device ID
const deviceID = data.deviceID.trim().toUpperCase(); const deviceID = data.deviceID.trim().toUpperCase();
document.getElementById('pageTitle_plus_ID').innerText = 'token: ' + deviceID; //document.getElementById('pageTitle_plus_ID').innerText = 'token: ' + deviceID;
//get device Name
const deviceName = data.deviceName;
const elements = document.querySelectorAll('.sideBar_sensorName');
elements.forEach((element) => {
element.innerText = deviceName;
});
//get local RTC //get local RTC
$.ajax({ $.ajax({

View File

@@ -100,16 +100,29 @@
}) })
.catch(error => console.error(`Error loading ${file}:`, error)); .catch(error => console.error(`Error loading ${file}:`, error));
}); });
}); });
window.onload = function() { window.onload = function() {
fetch('../config.json') // Replace 'deviceID.txt' with 'config.json' fetch('../config.json') // Replace 'deviceID.txt' with 'config.json'
.then(response => response.json()) // Parse response as JSON .then(response => response.json()) // Parse response as JSON
.then(data => { .then(data => {
console.log("Getting config file (onload)"); console.log("Getting config file (onload)");
//get device ID //get device ID
const deviceID = data.deviceID.trim().toUpperCase(); const deviceID = data.deviceID.trim().toUpperCase();
document.getElementById('pageTitle_plus_ID').innerText = 'token: ' + deviceID; //document.getElementById('pageTitle_plus_ID').innerText = 'token: ' + deviceID;
//get device Name
const deviceName = data.deviceName;
const elements = document.querySelectorAll('.sideBar_sensorName');
elements.forEach((element) => {
element.innerText = deviceName;
});
//get local RTC //get local RTC
$.ajax({ $.ajax({

View File

@@ -12,6 +12,12 @@ if ($type == "git_pull") {
echo $output; echo $output;
} }
if ($type == "clear_loopLogs") {
$command = 'truncate -s 0 /var/www/nebuleair_pro_4g/logs/loop.log';
$output = shell_exec($command);
echo $output;
}
if ($type == "linux_disk") { if ($type == "linux_disk") {
$command = 'df -h /'; $command = 'df -h /';
$output = shell_exec($command); $output = shell_exec($command);

View File

@@ -56,7 +56,8 @@
<div class="col-lg-6 col-12"> <div class="col-lg-6 col-12">
<div class="card" style="height: 80vh;"> <div class="card" style="height: 80vh;">
<div class="card-header"> <div class="card-header">
Loop logs Loop logs <button type="submit" class="btn btn-secondary btn-sm" onclick="clear_loopLogs()">Clear</button>
</div> </div>
<div class="card-body overflow-auto" id="card_loop_content"> <div class="card-body overflow-auto" id="card_loop_content">
@@ -172,6 +173,14 @@ window.onload = function() {
//get device ID //get device ID
const deviceID = data.deviceID.trim().toUpperCase(); const deviceID = data.deviceID.trim().toUpperCase();
document.getElementById('pageTitle_plus_ID').innerText = 'token: ' + deviceID; document.getElementById('pageTitle_plus_ID').innerText = 'token: ' + deviceID;
//get device Name
const deviceName = data.deviceName;
const elements = document.querySelectorAll('.sideBar_sensorName');
elements.forEach((element) => {
element.innerText = deviceName;
});
//get local RTC //get local RTC
$.ajax({ $.ajax({
@@ -191,6 +200,27 @@ window.onload = function() {
}) })
.catch(error => console.error('Error loading config.json:', error)); .catch(error => console.error('Error loading config.json:', error));
} }
function clear_loopLogs(){
console.log("Clearing loop logs");
$.ajax({
url: 'launcher.php?type=clear_loopLogs',
method: 'GET', // Use GET or POST depending on your needs
success: function(response) {
// Handle success response if needed
console.log(response);
//alert(response);
// Reload the page after the device update
location.reload(); // This will reload the page
},
error: function(xhr, status, error) {
console.error('AJAX request failed:', status, error);
}
});
}
</script> </script>
</body> </body>

View File

@@ -594,7 +594,16 @@ window.onload = function() {
.then(data => { .then(data => {
//get device ID //get device ID
const deviceID = data.deviceID.trim().toUpperCase(); const deviceID = data.deviceID.trim().toUpperCase();
document.getElementById('pageTitle_plus_ID').innerText = 'token: ' + deviceID; //document.getElementById('pageTitle_plus_ID').innerText = 'token: ' + deviceID;
//get device Name
const deviceName = data.deviceName;
const elements = document.querySelectorAll('.sideBar_sensorName');
elements.forEach((element) => {
element.innerText = deviceName;
});
//get SARA_R4 connection status //get SARA_R4 connection status
const SARA_statusElement = document.getElementById("modem-status"); const SARA_statusElement = document.getElementById("modem-status");

View File

@@ -41,4 +41,11 @@
Admin Admin
</a> </a>
<!-- New content at the bottom -->
<div class="sidebar-footer text-center text-white">
<hr>
<span class="sideBar_sensorName"> NebuleAir</span>
</div>
</nav> </nav>

View File

@@ -8,8 +8,9 @@
<button class="btn btn-outline-light d-md-none me-2" type="button" data-bs-toggle="offcanvas" data-bs-target="#sidebarOffcanvas" aria-controls="sidebarOffcanvas" aria-label="Toggle Sidebar"></button> <button class="btn btn-outline-light d-md-none me-2" type="button" data-bs-toggle="offcanvas" data-bs-target="#sidebarOffcanvas" aria-controls="sidebarOffcanvas" aria-label="Toggle Sidebar"></button>
<!-- Centered text --> <!-- Centered text -->
<!--
<span id="pageTitle_plus_ID" class="position-absolute top-50 start-50 translate-middle">Texte au milieu</span> <span id="pageTitle_plus_ID" class="position-absolute top-50 start-50 translate-middle">Texte au milieu</span>
-->
<button type="button" class="btn btn-outline-light" id="RTC_time">loading...</button> <button type="button" class="btn btn-outline-light" id="RTC_time">loading...</button>
</div> </div>

View File

@@ -292,7 +292,16 @@ function get_internet(){
console.log("Getting config file (onload)"); console.log("Getting config file (onload)");
//get device ID //get device ID
const deviceID = data.deviceID.trim().toUpperCase(); const deviceID = data.deviceID.trim().toUpperCase();
document.getElementById('pageTitle_plus_ID').innerText = 'token: ' + deviceID; //document.getElementById('pageTitle_plus_ID').innerText = 'token: ' + deviceID;
//get device Name
const deviceName = data.deviceName;
const elements = document.querySelectorAll('.sideBar_sensorName');
elements.forEach((element) => {
element.innerText = deviceName;
});
//get wifi connection status //get wifi connection status
const WIFI_statusElement = document.getElementById("wifi-status"); const WIFI_statusElement = document.getElementById("wifi-status");