feat: add web UI with login, CRUD, admin, and API key management
- Add login page with JWT authentication - Add dashboard with stats and quick actions - Add links management page (full CRUD with search) - Add collections management page - Add API key management page with copy-to-clipboard - Add admin user management page (admin only) - Fix UUID type mismatches across all endpoints - Add updated_at column to api_keys and audit_log in schema.sql - Fix DB_PASSWORD default in docker-compose.yml - Add PyJWT to requirements.txt - Fix API docs URL (/docs instead of /api/docs) - Improve JS error handling (show actual messages) - Rewrite conftest.py with proper DB lifecycle management - Add 42 new integration tests (84 total, all passing) - test_admin.py: 15 tests for admin endpoints - test_auth_extended.py: 9 tests for API key CRUD - test_tags.py: 12 tests for tag endpoints - test_sync.py: 6 tests for sync endpoints
This commit is contained in:
27
LinkSyncServer/static/js/dashboard.js
Normal file
27
LinkSyncServer/static/js/dashboard.js
Normal file
@@ -0,0 +1,27 @@
|
||||
document.addEventListener('DOMContentLoaded', async function() {
|
||||
const user = JSON.parse(localStorage.getItem('user') || 'null');
|
||||
if (!user) {
|
||||
window.location.href = '/login';
|
||||
return;
|
||||
}
|
||||
|
||||
document.getElementById('current-user').textContent = user.username;
|
||||
|
||||
if (user.role === 'admin') {
|
||||
document.getElementById('admin-section').style.display = '';
|
||||
}
|
||||
|
||||
try {
|
||||
const [links, collections, keys] = await Promise.all([
|
||||
LinkSync.getLinks({ limit: 1 }),
|
||||
LinkSync.getCollections(),
|
||||
LinkSync.getApiKeys(),
|
||||
]);
|
||||
|
||||
document.getElementById('link-count').textContent = Array.isArray(links) ? links.length : 0;
|
||||
document.getElementById('collection-count').textContent = Array.isArray(collections) ? collections.length : 0;
|
||||
document.getElementById('api-key-count').textContent = Array.isArray(keys) ? keys.length : 0;
|
||||
} catch (err) {
|
||||
console.error('Failed to load stats:', err);
|
||||
}
|
||||
});
|
||||
Reference in New Issue
Block a user