updating database update
This commit is contained in:
@@ -0,0 +1,19 @@
|
|||||||
|
<?php
|
||||||
|
// Path to the folder
|
||||||
|
$folderPath = '/var/www/html/database_srv';
|
||||||
|
|
||||||
|
// Get a list of all files in the folder
|
||||||
|
$files = scandir($folderPath);
|
||||||
|
|
||||||
|
// Subtract 16*16 from the total number of files
|
||||||
|
$totalFiles = count($files) - (16 * 16);
|
||||||
|
|
||||||
|
// Calculate the percentage
|
||||||
|
$percentage = ($totalFiles / 485) * 100;
|
||||||
|
|
||||||
|
// Ensure the percentage is within the range 0-100
|
||||||
|
$percentage = max(0, min(100, $percentage));
|
||||||
|
|
||||||
|
// Display the percentage
|
||||||
|
echo round($percentage, 2);
|
||||||
|
?>
|
||||||
@@ -40,6 +40,27 @@ async function update_db(){
|
|||||||
loader.style.display="none";
|
loader.style.display="none";
|
||||||
button.style.display="block";
|
button.style.display="block";
|
||||||
}
|
}
|
||||||
|
async function update_percentage() {
|
||||||
|
var percentageElement = document.getElementById("percentage");
|
||||||
|
|
||||||
|
// Display loading indicator
|
||||||
|
percentageElement.innerHTML = "Loading...";
|
||||||
|
|
||||||
|
// Make an AJAX request to the PHP script
|
||||||
|
await fetch('/get_update_status.php')
|
||||||
|
.then(response => response.json())
|
||||||
|
.then(data => {
|
||||||
|
// Update the percentage on the webpage
|
||||||
|
percentageElement.innerHTML = "Status: " + data.percentage.toFixed(2) + "%";
|
||||||
|
})
|
||||||
|
.catch(error => {
|
||||||
|
// Display error message if request fails
|
||||||
|
percentageElement.innerHTML = "Error: " + error.message;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
// Call update_percentage() every 5 seconds
|
||||||
|
setInterval(update_percentage, 5000);
|
||||||
</script>
|
</script>
|
||||||
<div class="container mt-5">
|
<div class="container mt-5">
|
||||||
<div class="row justify-content-center">
|
<div class="row justify-content-center">
|
||||||
@@ -54,6 +75,7 @@ async function update_db(){
|
|||||||
<br>
|
<br>
|
||||||
<div class="alert alert-success" role="alert">
|
<div class="alert alert-success" role="alert">
|
||||||
Database update is running, please do not close this tab and do not navigate away!
|
Database update is running, please do not close this tab and do not navigate away!
|
||||||
|
<div id="percentage"></div>
|
||||||
</div>
|
</div>
|
||||||
<div class="spinner-border" role="status">
|
<div class="spinner-border" role="status">
|
||||||
<span class="visually-hidden">Loading...</span>
|
<span class="visually-hidden">Loading...</span>
|
||||||
|
|||||||
Reference in New Issue
Block a user