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

@@ -9,8 +9,10 @@
--border: #e2e8f0;
--success: #22c55e;
--error: #ef4444;
--warning: #f59e0b;
--radius: 8px;
--shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
--shadow-lg: 0 4px 12px rgba(0, 0, 0, 0.15);
}
* {
@@ -63,6 +65,598 @@ body {
color: var(--primary);
}
.nav-user {
display: flex;
align-items: center;
gap: 1rem;
}
.nav-user span {
font-weight: 500;
color: var(--text);
}
.btn {
display: inline-flex;
align-items: center;
justify-content: center;
padding: 0.625rem 1.25rem;
border-radius: var(--radius);
text-decoration: none;
font-weight: 500;
font-size: 0.875rem;
border: none;
cursor: pointer;
transition: background 0.2s, opacity 0.2s;
}
.btn:disabled {
opacity: 0.6;
cursor: not-allowed;
}
.btn-primary {
background: var(--primary);
color: white;
}
.btn-primary:hover:not(:disabled) {
background: var(--primary-hover);
}
.btn-secondary {
background: var(--secondary);
color: white;
}
.btn-secondary:hover:not(:disabled) {
background: #475569;
}
.btn-danger {
background: var(--error);
color: white;
}
.btn-danger:hover:not(:disabled) {
background: #dc2626;
}
.btn-outline {
background: transparent;
border: 1px solid var(--border);
color: var(--text);
}
.btn-outline:hover {
background: var(--bg);
}
.btn-sm {
padding: 0.375rem 0.75rem;
font-size: 0.75rem;
}
.btn-full {
width: 100%;
}
.btn-icon {
padding: 0.375rem;
background: transparent;
border: none;
cursor: pointer;
color: var(--text-muted);
border-radius: 4px;
}
.btn-icon:hover {
background: var(--bg);
color: var(--text);
}
.page-header {
display: flex;
justify-content: space-between;
align-items: center;
margin-bottom: 1.5rem;
}
.page-header h1 {
font-size: 1.75rem;
}
.search-bar {
display: flex;
gap: 0.75rem;
margin-bottom: 1.5rem;
}
.search-bar input {
flex: 1;
padding: 0.625rem 1rem;
border: 1px solid var(--border);
border-radius: var(--radius);
font-size: 0.875rem;
}
.form-group {
margin-bottom: 1rem;
}
.form-group label {
display: block;
font-size: 0.875rem;
font-weight: 500;
margin-bottom: 0.375rem;
}
.form-group input,
.form-group textarea,
.form-group select {
width: 100%;
padding: 0.625rem 0.75rem;
border: 1px solid var(--border);
border-radius: var(--radius);
font-size: 0.875rem;
font-family: inherit;
}
.form-group input:focus,
.form-group textarea:focus,
.form-group select:focus {
outline: none;
border-color: var(--primary);
box-shadow: 0 0 0 2px rgba(37, 99, 235, 0.1);
}
.form-group textarea {
resize: vertical;
}
.checkbox-group label {
display: flex;
align-items: center;
gap: 0.5rem;
cursor: pointer;
}
.checkbox-group input[type="checkbox"] {
width: auto;
}
.form-actions {
display: flex;
gap: 0.75rem;
justify-content: flex-end;
margin-top: 1.5rem;
}
.error-message {
background: #fef2f2;
color: var(--error);
padding: 0.75rem 1rem;
border-radius: var(--radius);
margin-bottom: 1rem;
font-size: 0.875rem;
}
.success-message {
background: #f0fdf4;
color: var(--success);
padding: 0.75rem 1rem;
border-radius: var(--radius);
margin-bottom: 1rem;
font-size: 0.875rem;
}
.loading {
text-align: center;
padding: 2rem;
color: var(--text-muted);
}
.empty-state {
text-align: center;
padding: 3rem;
color: var(--text-muted);
}
.empty-state p {
margin-bottom: 1rem;
}
/* Login Page */
.login-page {
display: flex;
align-items: center;
justify-content: center;
min-height: 100vh;
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
}
.login-container {
width: 100%;
max-width: 400px;
padding: 1rem;
}
.login-card {
background: var(--surface);
padding: 2.5rem;
border-radius: var(--radius);
box-shadow: var(--shadow-lg);
}
.login-card h1 {
text-align: center;
color: var(--primary);
margin-bottom: 0.5rem;
}
.login-subtitle {
text-align: center;
color: var(--text-muted);
margin-bottom: 2rem;
}
/* Dashboard */
.dashboard-header {
margin-bottom: 2rem;
}
.dashboard-header h1 {
font-size: 1.75rem;
margin-bottom: 0.25rem;
}
.welcome-text {
color: var(--text-muted);
}
.stats-grid {
display: grid;
grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
gap: 1.5rem;
margin-bottom: 2.5rem;
}
.stat-card {
background: var(--surface);
border: 1px solid var(--border);
border-radius: var(--radius);
padding: 1.5rem;
text-align: center;
box-shadow: var(--shadow);
}
.stat-value {
font-size: 2.5rem;
font-weight: 700;
color: var(--primary);
}
.stat-label {
color: var(--text-muted);
font-size: 0.875rem;
margin: 0.25rem 0 0.75rem;
}
.stat-link {
color: var(--primary);
text-decoration: none;
font-size: 0.875rem;
font-weight: 500;
}
.stat-link:hover {
text-decoration: underline;
}
.quick-actions h2,
.admin-quick h2 {
font-size: 1.25rem;
margin-bottom: 1rem;
}
.action-grid {
display: grid;
grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
gap: 1rem;
margin-bottom: 2rem;
}
.action-card {
background: var(--surface);
border: 1px solid var(--border);
border-radius: var(--radius);
padding: 1.25rem;
text-align: center;
text-decoration: none;
transition: box-shadow 0.2s, border-color 0.2s;
}
.action-card:hover {
box-shadow: var(--shadow-lg);
border-color: var(--primary);
}
.action-icon {
display: block;
font-size: 1.5rem;
margin-bottom: 0.5rem;
}
.action-label {
color: var(--text);
font-weight: 500;
font-size: 0.875rem;
}
/* Tables */
.data-table {
width: 100%;
background: var(--surface);
border: 1px solid var(--border);
border-radius: var(--radius);
overflow: hidden;
box-shadow: var(--shadow);
}
.data-table table {
width: 100%;
border-collapse: collapse;
}
.data-table th,
.data-table td {
padding: 0.75rem 1rem;
text-align: left;
border-bottom: 1px solid var(--border);
}
.data-table th {
background: var(--bg);
font-weight: 600;
font-size: 0.75rem;
text-transform: uppercase;
letter-spacing: 0.05em;
color: var(--text-muted);
}
.data-table td {
font-size: 0.875rem;
}
.data-table tr:last-child td {
border-bottom: none;
}
.data-table tr:hover td {
background: #f8fafc;
}
.data-table .actions {
display: flex;
gap: 0.5rem;
}
.data-table .truncate {
max-width: 300px;
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
}
/* Links page */
.links-table .link-url {
color: var(--primary);
text-decoration: none;
}
.links-table .link-url:hover {
text-decoration: underline;
}
.links-table .tags {
display: flex;
flex-wrap: wrap;
gap: 0.25rem;
}
.links-table .tag {
background: #e0e7ff;
color: #3730a3;
padding: 0.125rem 0.5rem;
border-radius: 9999px;
font-size: 0.75rem;
}
/* Collections grid */
.collections-grid {
display: grid;
grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
gap: 1.5rem;
}
.collection-card {
background: var(--surface);
border: 1px solid var(--border);
border-radius: var(--radius);
padding: 1.25rem;
box-shadow: var(--shadow);
}
.collection-card h3 {
margin-bottom: 0.5rem;
color: var(--text);
}
.collection-card p {
color: var(--text-muted);
font-size: 0.875rem;
margin-bottom: 0.75rem;
}
.collection-card .meta {
display: flex;
justify-content: space-between;
align-items: center;
font-size: 0.75rem;
color: var(--text-muted);
margin-bottom: 0.75rem;
}
.collection-card .badge {
display: inline-block;
padding: 0.125rem 0.5rem;
border-radius: 9999px;
font-size: 0.75rem;
font-weight: 500;
}
.badge-static {
background: #dbeafe;
color: #1e40af;
}
.badge-dynamic {
background: #fef3c7;
color: #92400e;
}
.badge-public {
background: #dcfce7;
color: #166534;
}
.badge-private {
background: #f1f5f9;
color: #475569;
}
.collection-card .actions {
display: flex;
gap: 0.5rem;
padding-top: 0.75rem;
border-top: 1px solid var(--border);
}
/* API Keys */
.api-keys-table .key-value {
font-family: "Fira Code", "Cascadia Code", monospace;
font-size: 0.75rem;
color: var(--text-muted);
}
.api-keys-table .status-active {
color: var(--success);
font-weight: 500;
}
.api-keys-table .status-inactive {
color: var(--error);
font-weight: 500;
}
.key-result {
margin: 1rem 0;
}
.key-display {
display: flex;
gap: 0.5rem;
align-items: center;
background: var(--bg);
padding: 0.75rem 1rem;
border-radius: var(--radius);
margin: 0.75rem 0;
}
.key-display code {
flex: 1;
font-family: "Fira Code", "Cascadia Code", monospace;
font-size: 0.875rem;
word-break: break-all;
}
/* Users table */
.users-table .role-badge {
display: inline-block;
padding: 0.125rem 0.5rem;
border-radius: 9999px;
font-size: 0.75rem;
font-weight: 500;
}
.role-admin {
background: #fef3c7;
color: #92400e;
}
.role-user {
background: #e0e7ff;
color: #3730a3;
}
/* Modal */
.modal {
position: fixed;
inset: 0;
z-index: 1000;
display: flex;
align-items: center;
justify-content: center;
}
.modal-overlay {
position: absolute;
inset: 0;
background: rgba(0, 0, 0, 0.5);
}
.modal-content {
position: relative;
background: var(--surface);
border-radius: var(--radius);
padding: 1.5rem;
width: 100%;
max-width: 500px;
max-height: 90vh;
overflow-y: auto;
box-shadow: var(--shadow-lg);
}
.modal-content.modal-sm {
max-width: 400px;
}
.modal-header {
display: flex;
justify-content: space-between;
align-items: center;
margin-bottom: 1.25rem;
}
.modal-header h2 {
font-size: 1.25rem;
}
.modal-close {
background: none;
border: none;
font-size: 1.5rem;
cursor: pointer;
color: var(--text-muted);
padding: 0.25rem;
line-height: 1;
}
.modal-close:hover {
color: var(--text);
}
/* Hero (legacy) */
.hero {
text-align: center;
padding: 4rem 1rem;
@@ -85,33 +679,6 @@ body {
justify-content: center;
}
.btn {
display: inline-block;
padding: 0.75rem 1.5rem;
border-radius: var(--radius);
text-decoration: none;
font-weight: 500;
transition: background 0.2s;
}
.btn-primary {
background: var(--primary);
color: white;
}
.btn-primary:hover {
background: var(--primary-hover);
}
.btn-secondary {
background: var(--secondary);
color: white;
}
.btn-secondary:hover {
background: #475569;
}
.section {
margin: 3rem 0;
}
@@ -207,4 +774,15 @@ body {
.hero-actions {
flex-direction: column;
}
.page-header {
flex-direction: column;
gap: 1rem;
align-items: flex-start;
}
.data-table {
overflow-x: auto;
}
.data-table table {
min-width: 600px;
}
}