This commit is contained in:
PaulVua
2025-02-07 15:04:11 +01:00
parent fb44b57ac1
commit 7cac769795
4 changed files with 279 additions and 195 deletions

View File

@@ -57,7 +57,7 @@
<div class="card" style="height: 80vh;">
<div class="card-header">
Master logs <button type="submit" class="btn btn-secondary btn-sm" onclick="clear_loopLogs()">Clear</button>
<span id="script_running"></span>
</div>
<div class="card-body overflow-auto" id="card_loop_content">
@@ -166,6 +166,9 @@
window.onload = function() {
getModem_busy_status();
setInterval(getModem_busy_status, 2000);
fetch('../config.json') // Replace 'deviceID.txt' with 'config.json'
.then(response => response.json()) // Parse response as JSON
.then(data => {
@@ -221,6 +224,37 @@ function clear_loopLogs(){
}
});
}
function getModem_busy_status() {
console.log("Getting modem busy status");
const script_is_running = document.getElementById("script_running");
$.ajax({
url: 'launcher.php?type=getModem_busy',
dataType: 'json', // Expecting JSON response
method: 'GET',
success: function(response) {
console.log(response);
if (response.running) {
// Script is running → Show the Bootstrap spinner
script_is_running.innerHTML = `
<div class="spinner-border text-danger" role="status">
<span class="visually-hidden">Modem is busy...</span>
</div>
`;
} else {
// Script is NOT running → Show a success message (no spinner)
script_is_running.innerHTML = ``;
}
},
error: function(xhr, status, error) {
console.error('AJAX request failed:', status, error);
script_is_running.innerHTML = `<span class="text-warning">Error checking status ⚠️</span>`;
}
});
}
</script>
</body>