Spaces:
Sleeping
Sleeping
File size: 9,594 Bytes
c024705 eeacc46 c024705 eeacc46 c024705 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 |
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Dashboard Test</title>
<style>
body { font-family: Arial, sans-serif; margin: 20px; background: #f4f4f4; }
.test-container { max-width: 800px; margin: 0 auto; background: white; padding: 20px; border-radius: 8px; box-shadow: 0 2px 10px rgba(0,0,0,0.1); }
.test-section { margin: 20px 0; padding: 15px; border: 1px solid #ddd; border-radius: 5px; }
.success { background-color: #d4edda; border-color: #c3e6cb; }
.error { background-color: #f8d7da; border-color: #f5c6cb; }
.warning { background-color: #fff3cd; border-color: #ffeaa7; }
.info { background-color: #d1ecf1; border-color: #bee5eb; }
button { padding: 10px 20px; margin: 5px; cursor: pointer; border: none; border-radius: 4px; }
.btn-primary { background: #007bff; color: white; }
.btn-success { background: #28a745; color: white; }
.btn-warning { background: #ffc107; color: black; }
.btn-danger { background: #dc3545; color: white; }
.status { padding: 10px; margin: 10px 0; border-radius: 4px; }
.loading { color: #007bff; }
.success-text { color: #28a745; }
.error-text { color: #dc3545; }
</style>
</head>
<body>
<div class="test-container">
<h1>π§ AIMHSA Admin Dashboard Test</h1>
<p>This page tests the admin dashboard functionality and API connectivity.</p>
<div class="test-section">
<h3>1. Dashboard Access Test</h3>
<button class="btn-primary" onclick="testDashboardAccess()">Test Dashboard Access</button>
<div id="dashboard-result" class="status"></div>
</div>
<div class="test-section">
<h3>2. API Connectivity Test</h3>
<button class="btn-success" onclick="testAPIConnectivity()">Test API Endpoints</button>
<div id="api-result" class="status"></div>
</div>
<div class="test-section">
<h3>3. Database Schema Test</h3>
<button class="btn-warning" onclick="testDatabaseSchema()">Test Database Schema</button>
<div id="database-result" class="status"></div>
</div>
<div class="test-section">
<h3>4. Quick Actions</h3>
<button class="btn-primary" onclick="openDashboard()">Open Admin Dashboard</button>
<button class="btn-success" onclick="openTestPage()">Open Test Page</button>
<button class="btn-warning" onclick="checkConsole()">Check Console</button>
</div>
<div class="test-section info">
<h3>π Test Results Summary</h3>
<div id="summary-result">
<p>Click the test buttons above to run diagnostics.</p>
</div>
</div>
</div>
<script>
let testResults = {
dashboard: false,
api: false,
database: false
};
function testDashboardAccess() {
const result = document.getElementById('dashboard-result');
result.innerHTML = '<div class="loading">π Testing dashboard access...</div>';
try {
// Test if we can access the dashboard
fetch('admin_dashboard.html')
.then(response => {
if (response.ok) {
result.innerHTML = '<div class="success">β
Dashboard HTML accessible</div>';
testResults.dashboard = true;
updateSummary();
} else {
result.innerHTML = '<div class="error">β Dashboard HTML not accessible (Status: ' + response.status + ')</div>';
}
})
.catch(error => {
result.innerHTML = '<div class="error">β Error accessing dashboard: ' + error.message + '</div>';
});
} catch (error) {
result.innerHTML = '<div class="error">β Error: ' + error.message + '</div>';
}
}
function testAPIConnectivity() {
const result = document.getElementById('api-result');
result.innerHTML = '<div class="loading">π Testing API connectivity...</div>';
const endpoints = [
{ name: 'Admin Bookings', url: 'https://prodevroger-ishingiro.hf.space/admin/bookings' },
{ name: 'Admin Professionals', url: 'https://prodevroger-ishingiro.hf.space/admin/professionals' },
{ name: 'Admin Risk Assessments', url: 'https://prodevroger-ishingiro.hf.space/admin/risk-assessments' },
{ name: 'Monitor Risk Stats', url: 'https://prodevroger-ishingiro.hf.space/monitor/risk-stats' }
];
let results = [];
let completed = 0;
endpoints.forEach(endpoint => {
fetch(endpoint.url)
.then(response => {
const status = response.ok ? 'β
OK' : 'β Error (' + response.status + ')';
results.push(`${endpoint.name}: ${status}`);
completed++;
if (completed === endpoints.length) {
result.innerHTML = '<div>' + results.join('<br>') + '</div>';
testResults.api = results.some(r => r.includes('β
'));
updateSummary();
}
})
.catch(error => {
results.push(`${endpoint.name}: β ${error.message}`);
completed++;
if (completed === endpoints.length) {
result.innerHTML = '<div>' + results.join('<br>') + '</div>';
testResults.api = false;
updateSummary();
}
});
});
}
function testDatabaseSchema() {
const result = document.getElementById('database-result');
result.innerHTML = '<div class="loading">π Testing database schema...</div>';
// Test if we can get data from the database through API
fetch('https://prodevroger-ishingiro.hf.space/admin/professionals')
.then(response => response.json())
.then(data => {
if (data.professionals && Array.isArray(data.professionals)) {
result.innerHTML = `<div class="success">β
Database schema working<br>Found ${data.professionals.length} professionals</div>`;
testResults.database = true;
} else {
result.innerHTML = '<div class="warning">β οΈ Database accessible but no data found</div>';
testResults.database = true;
}
updateSummary();
})
.catch(error => {
result.innerHTML = '<div class="error">β Database error: ' + error.message + '</div>';
testResults.database = false;
updateSummary();
});
}
function updateSummary() {
const summary = document.getElementById('summary-result');
const passed = Object.values(testResults).filter(Boolean).length;
const total = Object.keys(testResults).length;
let summaryHtml = `<h4>Test Results: ${passed}/${total} passed</h4>`;
summaryHtml += `<ul>`;
summaryHtml += `<li>Dashboard Access: ${testResults.dashboard ? 'β
Pass' : 'β Fail'}</li>`;
summaryHtml += `<li>API Connectivity: ${testResults.api ? 'β
Pass' : 'β Fail'}</li>`;
summaryHtml += `<li>Database Schema: ${testResults.database ? 'β
Pass' : 'β Fail'}</li>`;
summaryHtml += `</ul>`;
if (passed === total) {
summaryHtml += '<div class="success">π All tests passed! Dashboard should work properly.</div>';
} else if (passed > 0) {
summaryHtml += '<div class="warning">β οΈ Some tests failed. Dashboard may have limited functionality.</div>';
} else {
summaryHtml += '<div class="error">β All tests failed. Please check your setup.</div>';
}
summary.innerHTML = summaryHtml;
}
function openDashboard() {
window.open('admin_dashboard.html', '_blank');
}
function openTestPage() {
window.open('test_admin_dashboard.html', '_blank');
}
function checkConsole() {
alert('Please open the browser console (F12) to see detailed logs and any error messages.');
}
// Auto-run basic tests on page load
window.onload = function() {
console.log('π Dashboard Test Page Loaded');
console.log('π Available tests:');
console.log(' - testDashboardAccess()');
console.log(' - testAPIConnectivity()');
console.log(' - testDatabaseSchema()');
};
</script>
</body>
</html>
|