feat: Add VPN status label
All checks were successful
Check Code Quality / RuffCheck (push) Successful in 51s
Build Docker / BuildImage (push) Successful in 1m7s

This commit is contained in:
2026-03-23 18:54:26 +11:00
parent 8678711ab1
commit 7cdce566da
2 changed files with 35 additions and 0 deletions

View File

@@ -104,3 +104,11 @@ a:hover {
background-color: #444;
text-decoration: none;
}
.success {
color: #4CAF50;
}
.failure {
color: #f44336;
}

View File

@@ -64,4 +64,31 @@ document.addEventListener("DOMContentLoaded", () => {
console.error("Error fetching Links stats:", error);
});
}
// Check VPN status and display it
const vpnLink = document.getElementById("vpn");
if (vpnLink) {
fetch("https://vpn.woodburn.net.au/api/v1/status")
.then(response => response.json())
.then(data => {
if (!data.error) {
// Create a new span element to display the VPN status
const statusLabel = document.createElement("p");
statusLabel.classList.add("service-note");
statusLabel.textContent = data.connected ? "Connected" : "Disconnected";
if (data.connected) {
statusLabel.classList.add("success");
} else {
statusLabel.classList.add("failure");
}
// Append the status span to the VPN link
vpnLink.appendChild(statusLabel);
} else {
console.error("Error fetching VPN status:", data.error);
}
})
.catch(error => {
console.error("Error fetching VPN status:", error);
});
}
});