feat: Add refresh button to latency check
All checks were successful
Build Docker / Build_Docker (push) Successful in 36s
All checks were successful
Build Docker / Build_Docker (push) Successful in 36s
This commit is contained in:
parent
d393e01a91
commit
7296e5bc45
@ -188,7 +188,10 @@
|
|||||||
<th>Region</th>
|
<th>Region</th>
|
||||||
<th>Region ID</th>
|
<th>Region ID</th>
|
||||||
<th># of nodes</th>
|
<th># of nodes</th>
|
||||||
<th>Latency</th>
|
<th>Latency <svg xmlns="http://www.w3.org/2000/svg" height="1em" viewBox="0 0 24 24" width="1em" fill="currentColor" id="refresh-ping" style="color: rgb(255,255,255);">
|
||||||
|
<path d="M0 0h24v24H0z" fill="none"></path>
|
||||||
|
<path d="M17.65 6.35C16.2 4.9 14.21 4 12 4c-4.42 0-7.99 3.58-7.99 8s3.57 8 7.99 8c3.73 0 6.84-2.55 7.73-6h-2.08c-.82 2.33-3.04 4-5.65 4-3.31 0-6-2.69-6-6s2.69-6 6-6c1.66 0 3.14.69 4.22 1.78L13 11h7V4l-2.35 2.35z"></path>
|
||||||
|
</svg></th>
|
||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
<tbody>
|
<tbody>
|
||||||
@ -226,7 +229,7 @@
|
|||||||
</table>
|
</table>
|
||||||
</div>
|
</div>
|
||||||
<script>
|
<script>
|
||||||
function pingServer(id) {
|
function pingServer(id) {
|
||||||
return new Promise((resolve) => { // Always resolve the promise
|
return new Promise((resolve) => { // Always resolve the promise
|
||||||
if (!id) {
|
if (!id) {
|
||||||
resolve({ id, pingTime: null, error: "Error: Invalid server ID" });
|
resolve({ id, pingTime: null, error: "Error: Invalid server ID" });
|
||||||
@ -256,12 +259,21 @@ function pingServer(id) {
|
|||||||
resolve({ id, pingTime: null, error: `Error pinging server` });
|
resolve({ id, pingTime: null, error: `Error pinging server` });
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
function runPingTest() {
|
||||||
|
const regions = ["au", "eu", "na", "as", "ap"];
|
||||||
|
const pingPromises = regions.map(region => pingServer(region));
|
||||||
|
|
||||||
const regions = ["au","eu", "na", "as", "ap"];
|
regions.forEach(region => {
|
||||||
const pingPromises = regions.map(region => pingServer(region));
|
const spanId = `${region}-ping`;
|
||||||
|
const spanElement = document.getElementById(spanId);
|
||||||
|
if (spanElement) {
|
||||||
|
spanElement.textContent = "Pinging..."; // Show Pinging... while waiting for results
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
Promise.all(pingPromises)
|
|
||||||
|
Promise.all(pingPromises)
|
||||||
.then(results => {
|
.then(results => {
|
||||||
console.log("Ping results:", results);
|
console.log("Ping results:", results);
|
||||||
|
|
||||||
@ -281,6 +293,15 @@ Promise.all(pingPromises)
|
|||||||
.catch(error => {
|
.catch(error => {
|
||||||
console.error("Error pinging servers:", error);
|
console.error("Error pinging servers:", error);
|
||||||
});
|
});
|
||||||
|
}
|
||||||
|
runPingTest();
|
||||||
|
|
||||||
|
// Add event listener to the refresh link
|
||||||
|
document.getElementById('refresh-ping').addEventListener('click', function (event) {
|
||||||
|
event.preventDefault(); // Prevent the default link behavior
|
||||||
|
runPingTest(); // Re-run the ping test
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
</script>
|
</script>
|
||||||
</div>
|
</div>
|
||||||
|
Loading…
Reference in New Issue
Block a user