all working i think

This commit is contained in:
2025-07-28 06:21:45 -07:00
parent b740ba9991
commit 211930cde3
30 changed files with 900 additions and 117 deletions

58
archive/js_site/app.js Normal file
View File

@ -0,0 +1,58 @@
document.addEventListener('DOMContentLoaded', function () {
// Initially set button state to "Loading..."
updateButtonState("Loading...");
// Set an interval to check the API every second
setInterval(checkAPIStatus, 1000); // 1000 ms = 1 second
});
// Function to update the button text based on the API state
function updateButtonState(status) {
const button = document.getElementById('statusButton');
if (status === "active") {
button.innerHTML = "Stop Service";
button.style.backgroundColor = "#FF6347"; // Red for stopping
button.onclick = stopService;
} else if (status === "inactive") {
button.innerHTML = "Start Service";
button.style.backgroundColor = "#32CD32"; // Green for starting
button.onclick = startService;
} else if (status === "failed") {
button.innerHTML = "Service Failed!";
button.style.backgroundColor = "#FF6347"; // Red for failed
button.onclick = null;
}else {
button.innerHTML = "Unknown";
button.style.backgroundColor = "#808080"; // Gray for error
button.onclick = null;
}
}
// Simulate API call and handle response
function checkAPIStatus() {
// Replace with your actual API endpoint
fetch('http://172.17.0.1:5000/status')
.then(response => response.json())
.then(data => {
const apiStatus = data.Status;
updateButtonState(apiStatus);
})
.catch(error => {
console.error('Error fetching API status:', error);
updateButtonState('error');
});
}
// Function to start the service (this would make the API call to start it)
function startService() {
console.log('Starting service...');
// You can call an API to start the service here
}
// Function to stop the service (this would make the API call to stop it)
function stopService() {
console.log('Stopping service...');
// You can call an API to stop the service here
}

19
archive/js_site/index.php Normal file
View File

@ -0,0 +1,19 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>API Status Button</title>
<link rel="stylesheet" href="styles.css">
</head>
<body>
<div id="app">
<button id="statusButton" onclick="handleButtonClick()">Loading...</button>
</div>
<?php
$status = file_get_contents("http://172.17.0.1:5000/status");
echo $status;
?>
<script src="app.js"></script>
</body>
</html>

26
archive/js_site/style.css Normal file
View File

@ -0,0 +1,26 @@
body {
font-family: Arial, sans-serif;
display: flex;
justify-content: center;
align-items: center;
height: 100vh;
margin: 0;
background-color: #f4f4f9;
}
#app {
text-align: center;
}
button {
padding: 15px 30px;
font-size: 18px;
cursor: pointer;
border: none;
border-radius: 5px;
transition: background-color 0.3s ease;
}
button:active {
transform: scale(0.98);
}