Files
Warracker/frontend/status-test.html
sassanix 8f62a166a6 Status page added
Please refer to Changelogs.md
2025-03-06 22:06:44 -04:00

79 lines
2.6 KiB
HTML

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Status API Test</title>
<style>
body {
font-family: Arial, sans-serif;
line-height: 1.6;
padding: 20px;
max-width: 800px;
margin: 0 auto;
}
pre {
background-color: #f5f5f5;
padding: 10px;
border-radius: 5px;
overflow-x: auto;
}
button {
padding: 10px 15px;
background-color: #4CAF50;
color: white;
border: none;
border-radius: 4px;
cursor: pointer;
margin: 10px 0;
}
.error {
color: #F44336;
font-weight: bold;
}
</style>
</head>
<body>
<h1>Status API Test</h1>
<p>This page tests if the statistics API endpoint is working correctly.</p>
<button id="testBtn">Test Statistics API</button>
<h2>Results:</h2>
<pre id="results">Click the button to test the API</pre>
<script>
document.getElementById('testBtn').addEventListener('click', async () => {
const resultsElement = document.getElementById('results');
resultsElement.textContent = 'Testing...';
try {
// Test with fetch API
console.log('Testing /api/statistics endpoint...');
const response = await fetch('/api/statistics');
if (!response.ok) {
const errorText = await response.text();
throw new Error(`HTTP Error: ${response.status} - ${errorText}`);
}
const data = await response.json();
// Display results
resultsElement.textContent = 'SUCCESS! Statistics API returned:\n\n' +
JSON.stringify(data, null, 2);
// Create a direct link to main status page
const linkElement = document.createElement('p');
linkElement.innerHTML = '<a href="status.html">Go to Status Dashboard</a>';
document.body.appendChild(linkElement);
} catch (error) {
console.error('API test failed:', error);
resultsElement.innerHTML = `<span class="error">ERROR: ${error.message}</span>\n\n` +
'Check browser console for more details.';
}
});
</script>
</body>
</html>