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:
DavidSaylor
2026-05-21 07:21:49 -05:00
parent 09d30427f4
commit 77b076c7d7
31 changed files with 2740 additions and 213 deletions

View File

@@ -15,7 +15,20 @@ document.addEventListener("DOMContentLoaded", function () {
headers,
});
if (!response.ok) {
throw new Error(`API error: ${response.status}`);
let errorMsg = `HTTP ${response.status}`;
try {
const error = await response.json();
if (typeof error.detail === 'string') {
errorMsg = error.detail;
} else if (Array.isArray(error.detail)) {
errorMsg = error.detail.map(d => d.msg || d).join(', ');
} else if (error.detail && typeof error.detail === 'object') {
errorMsg = error.detail.detail || error.detail.msg || JSON.stringify(error.detail);
}
} catch {
// ignore parse error, use default
}
throw new Error(errorMsg);
}
return response.json();
}
@@ -50,6 +63,15 @@ document.addEventListener("DOMContentLoaded", function () {
body: JSON.stringify(data),
});
},
async updateCollection(id, data) {
return apiFetch(`/collections/${id}`, {
method: "PUT",
body: JSON.stringify(data),
});
},
async deleteCollection(id) {
return apiFetch(`/collections/${id}`, { method: "DELETE" });
},
async executeQuery(expression, limit = 20) {
return apiFetch(`/queries/execute?expression=${encodeURIComponent(expression)}&limit=${limit}`);
},
@@ -67,8 +89,41 @@ document.addEventListener("DOMContentLoaded", function () {
localStorage.setItem("token", data.access_token);
return data;
},
async getMe() {
return apiFetch("/auth/me");
},
logout() {
localStorage.removeItem("token");
localStorage.removeItem("user");
},
async getUsers() {
return apiFetch("/admin/users");
},
async createUser(data) {
return apiFetch("/admin/users", {
method: "POST",
body: JSON.stringify(data),
});
},
async updateUser(id, data) {
return apiFetch(`/admin/users/${id}`, {
method: "PUT",
body: JSON.stringify(data),
});
},
async deleteUser(id) {
return apiFetch(`/admin/users/${id}`, { method: "DELETE" });
},
async getApiKeys() {
return apiFetch("/auth/api-keys");
},
async createApiKey(name) {
return apiFetch(`/auth/api-key?name=${encodeURIComponent(name)}`, {
method: "POST",
});
},
async deleteApiKey(id) {
return apiFetch(`/auth/api-key/${id}`, { method: "DELETE" });
},
};
});