This squashes 13 commits from ma/staging plus a small docstring translation
into a single coherent unit. Three workstreams.
== RBAC v13 redesign ==
- Drops core.viewer/analyst/km_admin/admin hierarchy and the
internal_roles / group_mappings / user_role_grants / plugin_access tables.
- Replaced by user_group_members + resource_grants. Atomic v12→v13 backfill
wrapped in BEGIN/COMMIT; ROLLBACK leaves schema_version at 12 for retry.
- Two authorization primitives in app.auth.access:
require_admin — Admin-group god-mode
require_resource_access(rt, "{path}") — entity-scoped grants
Single DB lookup per request; no session cache; no implies BFS.
- /admin/access UI (single page) replaces /admin/role-mapping +
/admin/plugin-access. CLI `da admin group/grant *` replaces
`da admin role/mapping/grant-role/revoke-role/effective-roles`.
- ResourceType.TABLE listing-only — admins can record table grants,
runtime enforcement still flows through legacy dataset_permissions
(migration plan in docs/TODO-rbac-data-enforcement.md).
== Claude Code marketplace ==
- Aggregated /marketplace.zip + /marketplace.git/* (PAT-gated,
RBAC-filtered, content-addressed cache via dulwich).
- Admin god-mode dropped on the marketplace surface — admins curate
their own view via grants like everyone else.
- Bare-repo cache materializes per RBAC-filtered ETag; stale entries
not pruned in this iteration (disclaimed in git_backend.py docstring).
== #81 #83 #44 security/ops hardening ==
- #81 Group A — orchestrator ATTACH allow-listing (extension/url/alias).
- #81 Group B — Keboola extractor 3-state exit codes:
0 success / 1 total fail / 2 PARTIAL fail
Sync API logs PARTIAL FAILURE alert on exit 2. Operators with binary
alerting must teach it the new partial signal.
- #81 Group C — schema v10 view_ownership; rejects silent overwrite
of a prior connector's view name on collision.
- #81 Group D — extractor-side identifier validation.
- #83 — Jira webhook fail-closed when JIRA_WEBHOOK_SECRET unset
+ path-traversal fix.
- #44 — entire /api/scripts/* surface is admin-only (planted-script +
sandbox-bypass risk closed).
== Web UI polish + deploy fix ==
- /admin/access: live grant-count badges (no stale snapshot revert),
shared-header CSS link added to /catalog and /admin/{tables,permissions},
per-resource-type colored stripes.
- docker-compose.host-mount.yml: bind,rbind so dual-disk hosts don't
silently shadow sub-mounts and write state to the wrong disk.
== OSS vendor-neutralization (waves 1+2) ==
- scripts/grpn/ → scripts/ops/. Customer-specific identifiers
(project IDs, internal hostnames, dev/prod VM IPs, brand names)
replaced with placeholders across code, docs, Terraform, Caddyfile,
OAuth probe, and planning docs. Downstream infra repos that copied
scripts/grpn/agnes-tls-rotate.sh or agnes-auto-upgrade.sh must
update the path.
== Translation ==
- src/repositories/user_groups.py::ensure_system docstring translated
from Czech to English for codebase consistency.
Co-authored-by: Mina Rustamyan <mina@keboola.com>
1321 lines
46 KiB
HTML
1321 lines
46 KiB
HTML
<!DOCTYPE html>
|
|
<html lang="en">
|
|
<head>
|
|
<meta charset="UTF-8">
|
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
<title>Table Management - {{ config.INSTANCE_NAME }}</title>
|
|
{% if not config.THEME_FONT_URL %}
|
|
<link rel="preconnect" href="https://fonts.googleapis.com">
|
|
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
|
|
<link href="https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap" rel="stylesheet">
|
|
{% endif %}
|
|
<link rel="stylesheet" href="{{ url_for('static', filename='style-custom.css') }}">
|
|
<style>
|
|
:root {
|
|
/* Colors - Design System */
|
|
--primary: #0073D1;
|
|
--primary-light: rgba(0, 115, 209, 0.1);
|
|
--text-primary: #1A253C;
|
|
--text-secondary: #6B7280;
|
|
--background: #F5F7FA;
|
|
--surface: #FFFFFF;
|
|
--border: #E5E7EB;
|
|
--border-light: #F3F4F6;
|
|
--success: #10B77F;
|
|
--success-light: rgba(16, 183, 127, 0.1);
|
|
--warning: #F59F0A;
|
|
--error: #EA580C;
|
|
--error-light: rgba(234, 88, 12, 0.1);
|
|
|
|
/* Typography */
|
|
--font-primary: 'Inter', system-ui, sans-serif;
|
|
--font-mono: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
|
|
|
|
/* Shadows */
|
|
--shadow-sm: rgba(0, 0, 0, 0.05) 0px 1px 2px 0px;
|
|
--shadow-md: rgba(0, 0, 0, 0.1) 0px 4px 6px -1px;
|
|
}
|
|
|
|
* {
|
|
margin: 0;
|
|
padding: 0;
|
|
box-sizing: border-box;
|
|
}
|
|
|
|
body {
|
|
font-family: var(--font-primary);
|
|
font-size: 14px;
|
|
color: var(--text-primary);
|
|
background: var(--background);
|
|
line-height: 1.5;
|
|
}
|
|
|
|
/* ── Header (dashboard-style) ── */
|
|
.header {
|
|
background: var(--surface);
|
|
border-bottom: 1px solid var(--border);
|
|
padding: 0 32px;
|
|
height: 72px;
|
|
display: flex;
|
|
align-items: center;
|
|
justify-content: space-between;
|
|
position: sticky;
|
|
top: 0;
|
|
z-index: 100;
|
|
}
|
|
|
|
.header-left {
|
|
display: flex;
|
|
align-items: center;
|
|
gap: 16px;
|
|
}
|
|
|
|
.header-back {
|
|
display: flex;
|
|
align-items: center;
|
|
justify-content: center;
|
|
width: 32px;
|
|
height: 32px;
|
|
border-radius: 6px;
|
|
color: var(--text-secondary);
|
|
text-decoration: none;
|
|
transition: all 0.15s ease;
|
|
}
|
|
|
|
.header-back:hover {
|
|
background: var(--border-light);
|
|
color: var(--text-primary);
|
|
}
|
|
|
|
.header-logo-group {
|
|
display: flex;
|
|
flex-direction: column;
|
|
justify-content: center;
|
|
gap: 2px;
|
|
}
|
|
|
|
.header-logo svg {
|
|
display: block;
|
|
}
|
|
|
|
.header-subtitle {
|
|
font-size: 11px;
|
|
font-weight: 500;
|
|
color: var(--text-secondary);
|
|
letter-spacing: 0.4px;
|
|
text-transform: uppercase;
|
|
margin-top: 2px;
|
|
}
|
|
|
|
.header-right {
|
|
font-size: 12px;
|
|
color: var(--text-secondary);
|
|
}
|
|
|
|
/* ── Page Title ── */
|
|
.page-title {
|
|
max-width: 1000px;
|
|
margin: 0 auto;
|
|
padding: 32px 24px 24px;
|
|
}
|
|
|
|
.page-title h1 {
|
|
font-size: 24px;
|
|
font-weight: 600;
|
|
color: var(--text-primary);
|
|
margin-bottom: 4px;
|
|
}
|
|
|
|
.page-title p {
|
|
font-size: 14px;
|
|
color: var(--text-secondary);
|
|
}
|
|
|
|
/* ── Content Layout ── */
|
|
.content {
|
|
max-width: 1000px;
|
|
margin: 0 auto;
|
|
padding: 0 24px 32px;
|
|
display: flex;
|
|
flex-direction: column;
|
|
gap: 24px;
|
|
}
|
|
|
|
/* ── Panel (shared card style) ── */
|
|
.panel {
|
|
background: var(--surface);
|
|
border: 1px solid var(--border);
|
|
border-radius: 12px;
|
|
overflow: hidden;
|
|
box-shadow: var(--shadow-sm);
|
|
}
|
|
|
|
.panel-header {
|
|
display: flex;
|
|
align-items: center;
|
|
justify-content: space-between;
|
|
padding: 20px 24px;
|
|
border-bottom: 1px solid var(--border-light);
|
|
}
|
|
|
|
.panel-header-left {
|
|
display: flex;
|
|
align-items: center;
|
|
gap: 12px;
|
|
}
|
|
|
|
.panel-header-icon {
|
|
width: 36px;
|
|
height: 36px;
|
|
border-radius: 8px;
|
|
display: flex;
|
|
align-items: center;
|
|
justify-content: center;
|
|
flex-shrink: 0;
|
|
background: var(--primary-light);
|
|
}
|
|
|
|
.panel-title {
|
|
font-size: 16px;
|
|
font-weight: 600;
|
|
color: var(--text-primary);
|
|
}
|
|
|
|
.panel-subtitle {
|
|
font-size: 13px;
|
|
color: var(--text-secondary);
|
|
margin-top: 1px;
|
|
}
|
|
|
|
.panel-body {
|
|
padding: 20px 24px;
|
|
}
|
|
|
|
.panel-body-empty {
|
|
padding: 40px 24px;
|
|
text-align: center;
|
|
color: var(--text-secondary);
|
|
font-size: 13px;
|
|
}
|
|
|
|
/* ── Buttons ── */
|
|
.btn {
|
|
display: inline-flex;
|
|
align-items: center;
|
|
gap: 6px;
|
|
padding: 8px 16px;
|
|
border: none;
|
|
border-radius: 8px;
|
|
font-family: var(--font-primary);
|
|
font-size: 13px;
|
|
font-weight: 500;
|
|
cursor: pointer;
|
|
transition: all 0.15s ease;
|
|
white-space: nowrap;
|
|
}
|
|
|
|
.btn-primary {
|
|
background: var(--primary);
|
|
color: white;
|
|
}
|
|
|
|
.btn-primary:hover {
|
|
background: #005FA8;
|
|
}
|
|
|
|
.btn-primary:disabled {
|
|
opacity: 0.6;
|
|
cursor: not-allowed;
|
|
}
|
|
|
|
.btn-secondary {
|
|
background: var(--border-light);
|
|
color: var(--text-primary);
|
|
}
|
|
|
|
.btn-secondary:hover {
|
|
background: var(--border);
|
|
}
|
|
|
|
.btn-danger {
|
|
background: var(--error-light);
|
|
color: var(--error);
|
|
}
|
|
|
|
.btn-danger:hover {
|
|
background: rgba(234, 88, 12, 0.2);
|
|
}
|
|
|
|
.btn-sm {
|
|
padding: 5px 10px;
|
|
font-size: 12px;
|
|
border-radius: 6px;
|
|
}
|
|
|
|
.btn-icon {
|
|
width: 28px;
|
|
height: 28px;
|
|
padding: 0;
|
|
display: flex;
|
|
align-items: center;
|
|
justify-content: center;
|
|
border-radius: 6px;
|
|
background: none;
|
|
border: none;
|
|
cursor: pointer;
|
|
color: var(--text-secondary);
|
|
transition: all 0.15s ease;
|
|
}
|
|
|
|
.btn-icon:hover {
|
|
background: var(--border-light);
|
|
color: var(--text-primary);
|
|
}
|
|
|
|
.btn-icon.danger:hover {
|
|
background: var(--error-light);
|
|
color: var(--error);
|
|
}
|
|
|
|
/* ── Badges ── */
|
|
.badge {
|
|
flex-shrink: 0;
|
|
font-size: 11px;
|
|
font-weight: 500;
|
|
border-radius: 6px;
|
|
padding: 3px 8px;
|
|
white-space: nowrap;
|
|
}
|
|
|
|
.badge-registered {
|
|
color: #065F46;
|
|
background: #D1FAE5;
|
|
}
|
|
|
|
.badge-available {
|
|
color: var(--primary);
|
|
background: var(--primary-light);
|
|
}
|
|
|
|
/* ── Spinner ── */
|
|
.spinner {
|
|
display: inline-block;
|
|
width: 18px;
|
|
height: 18px;
|
|
border: 2px solid var(--border);
|
|
border-top-color: var(--primary);
|
|
border-radius: 50%;
|
|
animation: spin 0.6s linear infinite;
|
|
}
|
|
|
|
@keyframes spin {
|
|
to { transform: rotate(360deg); }
|
|
}
|
|
|
|
.spinner-lg {
|
|
width: 32px;
|
|
height: 32px;
|
|
border-width: 3px;
|
|
}
|
|
|
|
/* ── Loading state ── */
|
|
.loading-state {
|
|
display: flex;
|
|
flex-direction: column;
|
|
align-items: center;
|
|
gap: 12px;
|
|
padding: 40px 24px;
|
|
color: var(--text-secondary);
|
|
font-size: 13px;
|
|
}
|
|
|
|
/* ── Notification toast ── */
|
|
.toast {
|
|
position: fixed;
|
|
top: 84px;
|
|
right: 24px;
|
|
z-index: 200;
|
|
background: var(--surface);
|
|
border: 1px solid var(--border);
|
|
border-radius: 10px;
|
|
box-shadow: var(--shadow-md);
|
|
padding: 12px 16px;
|
|
display: flex;
|
|
align-items: center;
|
|
gap: 10px;
|
|
font-size: 13px;
|
|
transform: translateX(120%);
|
|
transition: transform 0.3s ease;
|
|
max-width: 360px;
|
|
}
|
|
|
|
.toast.visible {
|
|
transform: translateX(0);
|
|
}
|
|
|
|
.toast-success {
|
|
border-left: 3px solid var(--success);
|
|
}
|
|
|
|
.toast-error {
|
|
border-left: 3px solid var(--error);
|
|
}
|
|
|
|
.toast-icon {
|
|
width: 20px;
|
|
height: 20px;
|
|
flex-shrink: 0;
|
|
}
|
|
|
|
/* ── Bucket accordion ── */
|
|
.bucket-group {
|
|
border-top: 1px solid var(--border-light);
|
|
}
|
|
|
|
.bucket-group:first-child {
|
|
border-top: none;
|
|
}
|
|
|
|
.bucket-trigger {
|
|
width: 100%;
|
|
display: flex;
|
|
align-items: center;
|
|
gap: 10px;
|
|
padding: 12px 24px;
|
|
background: none;
|
|
border: none;
|
|
cursor: pointer;
|
|
font-family: var(--font-primary);
|
|
font-size: 14px;
|
|
font-weight: 500;
|
|
color: var(--text-primary);
|
|
text-align: left;
|
|
transition: background 0.1s ease;
|
|
}
|
|
|
|
.bucket-trigger:hover {
|
|
background: var(--border-light);
|
|
}
|
|
|
|
.bucket-chevron {
|
|
width: 16px;
|
|
height: 16px;
|
|
color: var(--text-secondary);
|
|
transition: transform 0.2s ease;
|
|
flex-shrink: 0;
|
|
}
|
|
|
|
.bucket-trigger.expanded .bucket-chevron {
|
|
transform: rotate(90deg);
|
|
}
|
|
|
|
.bucket-count {
|
|
font-size: 11px;
|
|
font-weight: 500;
|
|
color: var(--text-secondary);
|
|
background: var(--border-light);
|
|
padding: 1px 7px;
|
|
border-radius: 9999px;
|
|
margin-left: auto;
|
|
}
|
|
|
|
.bucket-content {
|
|
display: none;
|
|
}
|
|
|
|
.bucket-content.expanded {
|
|
display: block;
|
|
}
|
|
|
|
/* ── Table row (discovery results) ── */
|
|
.table-item {
|
|
display: flex;
|
|
align-items: center;
|
|
padding: 10px 24px 10px 50px;
|
|
border-top: 1px solid var(--border-light);
|
|
gap: 12px;
|
|
transition: background 0.1s ease;
|
|
}
|
|
|
|
.table-item:hover {
|
|
background: rgba(243, 244, 246, 0.5);
|
|
}
|
|
|
|
.table-item-info {
|
|
flex: 1;
|
|
min-width: 0;
|
|
}
|
|
|
|
.table-item-name {
|
|
font-weight: 500;
|
|
font-family: var(--font-mono);
|
|
font-size: 13px;
|
|
color: var(--text-primary);
|
|
}
|
|
|
|
.table-item-meta {
|
|
font-size: 12px;
|
|
color: var(--text-secondary);
|
|
margin-top: 1px;
|
|
display: flex;
|
|
gap: 12px;
|
|
flex-wrap: wrap;
|
|
}
|
|
|
|
.table-item-actions {
|
|
display: flex;
|
|
align-items: center;
|
|
gap: 8px;
|
|
flex-shrink: 0;
|
|
}
|
|
|
|
/* ── Registry table ── */
|
|
.registry-table {
|
|
width: 100%;
|
|
border-collapse: collapse;
|
|
}
|
|
|
|
.registry-table th {
|
|
text-align: left;
|
|
font-size: 11px;
|
|
font-weight: 600;
|
|
color: var(--text-secondary);
|
|
text-transform: uppercase;
|
|
letter-spacing: 0.4px;
|
|
padding: 10px 16px;
|
|
border-bottom: 1px solid var(--border);
|
|
background: var(--background);
|
|
}
|
|
|
|
.registry-table td {
|
|
padding: 12px 16px;
|
|
font-size: 13px;
|
|
border-bottom: 1px solid var(--border-light);
|
|
vertical-align: middle;
|
|
}
|
|
|
|
.registry-table tr:last-child td {
|
|
border-bottom: none;
|
|
}
|
|
|
|
.registry-table tr:hover td {
|
|
background: rgba(243, 244, 246, 0.5);
|
|
}
|
|
|
|
.registry-table .col-id {
|
|
font-family: var(--font-mono);
|
|
font-size: 12px;
|
|
max-width: 280px;
|
|
overflow: hidden;
|
|
text-overflow: ellipsis;
|
|
white-space: nowrap;
|
|
}
|
|
|
|
.registry-table .col-strategy {
|
|
white-space: nowrap;
|
|
}
|
|
|
|
.registry-table .col-actions {
|
|
width: 80px;
|
|
text-align: right;
|
|
}
|
|
|
|
.strategy-badge {
|
|
font-size: 11px;
|
|
font-weight: 500;
|
|
padding: 2px 8px;
|
|
border-radius: 4px;
|
|
background: var(--border-light);
|
|
color: var(--text-secondary);
|
|
}
|
|
|
|
/* ── Modal overlay ── */
|
|
.modal-overlay {
|
|
display: none;
|
|
position: fixed;
|
|
top: 0;
|
|
left: 0;
|
|
right: 0;
|
|
bottom: 0;
|
|
background: rgba(0, 0, 0, 0.5);
|
|
z-index: 1000;
|
|
padding: 40px 24px;
|
|
overflow-y: auto;
|
|
}
|
|
|
|
.modal-overlay.active {
|
|
display: flex;
|
|
align-items: flex-start;
|
|
justify-content: center;
|
|
}
|
|
|
|
.modal {
|
|
max-width: 560px;
|
|
width: 100%;
|
|
background: var(--surface);
|
|
border-radius: 12px;
|
|
box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
|
|
overflow: hidden;
|
|
}
|
|
|
|
.modal-header {
|
|
display: flex;
|
|
justify-content: space-between;
|
|
align-items: center;
|
|
padding: 20px 24px;
|
|
border-bottom: 1px solid var(--border);
|
|
background: var(--background);
|
|
}
|
|
|
|
.modal-header h2 {
|
|
font-size: 18px;
|
|
font-weight: 600;
|
|
}
|
|
|
|
.modal-close {
|
|
width: 32px;
|
|
height: 32px;
|
|
border: none;
|
|
background: none;
|
|
cursor: pointer;
|
|
border-radius: 6px;
|
|
display: flex;
|
|
align-items: center;
|
|
justify-content: center;
|
|
color: var(--text-secondary);
|
|
transition: all 0.15s;
|
|
}
|
|
|
|
.modal-close:hover {
|
|
background: var(--border-light);
|
|
color: var(--text-primary);
|
|
}
|
|
|
|
.modal-body {
|
|
padding: 24px;
|
|
}
|
|
|
|
.modal-footer {
|
|
display: flex;
|
|
justify-content: flex-end;
|
|
gap: 10px;
|
|
padding: 16px 24px;
|
|
border-top: 1px solid var(--border);
|
|
background: var(--background);
|
|
}
|
|
|
|
/* ── Form ── */
|
|
.form-group {
|
|
margin-bottom: 18px;
|
|
}
|
|
|
|
.form-group:last-child {
|
|
margin-bottom: 0;
|
|
}
|
|
|
|
.form-label {
|
|
display: block;
|
|
font-size: 13px;
|
|
font-weight: 500;
|
|
color: var(--text-primary);
|
|
margin-bottom: 6px;
|
|
}
|
|
|
|
.form-label .optional {
|
|
font-weight: 400;
|
|
color: var(--text-secondary);
|
|
font-size: 12px;
|
|
}
|
|
|
|
.form-input,
|
|
.form-select,
|
|
.form-textarea {
|
|
width: 100%;
|
|
padding: 8px 12px;
|
|
border: 1px solid var(--border);
|
|
border-radius: 8px;
|
|
font-family: var(--font-primary);
|
|
font-size: 13px;
|
|
color: var(--text-primary);
|
|
background: var(--surface);
|
|
transition: border-color 0.15s;
|
|
}
|
|
|
|
.form-input:focus,
|
|
.form-select:focus,
|
|
.form-textarea:focus {
|
|
outline: none;
|
|
border-color: var(--primary);
|
|
box-shadow: 0 0 0 3px rgba(0, 115, 209, 0.1);
|
|
}
|
|
|
|
.form-input[readonly] {
|
|
background: var(--border-light);
|
|
color: var(--text-secondary);
|
|
cursor: not-allowed;
|
|
}
|
|
|
|
.form-textarea {
|
|
min-height: 80px;
|
|
resize: vertical;
|
|
}
|
|
|
|
.form-select {
|
|
cursor: pointer;
|
|
appearance: none;
|
|
background-image: url("data:image/svg+xml,%3Csvg width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%236B7280' stroke-width='2' stroke-linecap='round' stroke-linejoin='round' xmlns='http://www.w3.org/2000/svg'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
|
|
background-repeat: no-repeat;
|
|
background-position: right 12px center;
|
|
padding-right: 32px;
|
|
}
|
|
|
|
.form-hint {
|
|
font-size: 12px;
|
|
color: var(--text-secondary);
|
|
margin-top: 4px;
|
|
}
|
|
|
|
/* ── Footer ── */
|
|
.footer {
|
|
text-align: center;
|
|
padding: 24px;
|
|
color: var(--text-secondary);
|
|
font-size: 12px;
|
|
}
|
|
|
|
.footer a {
|
|
color: var(--primary);
|
|
text-decoration: none;
|
|
}
|
|
|
|
.footer a:hover {
|
|
text-decoration: underline;
|
|
}
|
|
|
|
/* ── Responsive ── */
|
|
@media (max-width: 640px) {
|
|
.header {
|
|
padding: 0 16px;
|
|
}
|
|
|
|
.page-title {
|
|
padding: 24px 16px 16px;
|
|
}
|
|
|
|
.content {
|
|
padding: 0 16px 24px;
|
|
}
|
|
|
|
.panel-header {
|
|
flex-direction: column;
|
|
align-items: flex-start;
|
|
gap: 12px;
|
|
}
|
|
|
|
.table-item {
|
|
padding-left: 24px;
|
|
flex-wrap: wrap;
|
|
}
|
|
|
|
.table-item-meta {
|
|
flex-direction: column;
|
|
gap: 4px;
|
|
}
|
|
|
|
.registry-table .col-id {
|
|
max-width: 160px;
|
|
}
|
|
|
|
.modal {
|
|
margin: 16px;
|
|
}
|
|
}
|
|
</style>
|
|
{% include '_theme.html' %}
|
|
</head>
|
|
<body>
|
|
|
|
<!-- ═══════════════ HEADER ═══════════════ -->
|
|
{% include '_app_header.html' %}
|
|
|
|
<!-- ═══════════════ PAGE TITLE ═══════════════ -->
|
|
<div class="page-title">
|
|
<h1>Table Management</h1>
|
|
<p>Discover, register, and manage data tables from your source</p>
|
|
</div>
|
|
|
|
<!-- ═══════════════ CONTENT ═══════════════ -->
|
|
<div class="content">
|
|
|
|
<!-- ── Discovery Panel ── -->
|
|
<div class="panel">
|
|
<div class="panel-header">
|
|
<div class="panel-header-left">
|
|
<div class="panel-header-icon">
|
|
<svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="#0073D1" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
|
|
<circle cx="11" cy="11" r="8"/>
|
|
<line x1="21" y1="21" x2="16.65" y2="16.65"/>
|
|
</svg>
|
|
</div>
|
|
<div>
|
|
<div class="panel-title">Discover Tables</div>
|
|
<div class="panel-subtitle">Scan your data source for available tables</div>
|
|
</div>
|
|
</div>
|
|
<button class="btn btn-primary" id="discoverBtn" onclick="discoverTables()">
|
|
<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
|
|
<circle cx="11" cy="11" r="8"/>
|
|
<line x1="21" y1="21" x2="16.65" y2="16.65"/>
|
|
</svg>
|
|
Discover tables from source
|
|
</button>
|
|
</div>
|
|
<div id="discoveryResults">
|
|
<div class="panel-body-empty" id="discoveryEmpty">
|
|
Click "Discover tables from source" to scan for available tables
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<!-- ── Registry Panel ── -->
|
|
<div class="panel">
|
|
<div class="panel-header">
|
|
<div class="panel-header-left">
|
|
<div class="panel-header-icon" style="background: var(--success-light);">
|
|
<svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="#10B77F" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
|
|
<path d="M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z"/>
|
|
<polyline points="14 2 14 8 20 8"/>
|
|
<line x1="16" y1="13" x2="8" y2="13"/>
|
|
<line x1="16" y1="17" x2="8" y2="17"/>
|
|
<polyline points="10 9 9 9 8 9"/>
|
|
</svg>
|
|
</div>
|
|
<div>
|
|
<div class="panel-title">Registered Tables</div>
|
|
<div class="panel-subtitle" id="registrySubtitle">Tables currently configured for sync</div>
|
|
</div>
|
|
</div>
|
|
<button class="btn btn-secondary btn-sm" onclick="loadRegistry()">
|
|
<svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
|
|
<polyline points="23 4 23 10 17 10"/>
|
|
<path d="M20.49 15a9 9 0 1 1-2.12-9.36L23 10"/>
|
|
</svg>
|
|
Refresh
|
|
</button>
|
|
</div>
|
|
<div id="registryContent">
|
|
<div class="loading-state" id="registryLoading">
|
|
<div class="spinner spinner-lg"></div>
|
|
<span>Loading registry...</span>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
</div>
|
|
|
|
<!-- ═══════════════ REGISTRATION MODAL ═══════════════ -->
|
|
<div class="modal-overlay" id="registerModal">
|
|
<div class="modal">
|
|
<div class="modal-header">
|
|
<h2>Register Table</h2>
|
|
<button class="modal-close" onclick="closeRegisterModal()">
|
|
<svg width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
|
|
<line x1="18" y1="6" x2="6" y2="18"/>
|
|
<line x1="6" y1="6" x2="18" y2="18"/>
|
|
</svg>
|
|
</button>
|
|
</div>
|
|
<div class="modal-body">
|
|
<div class="form-group">
|
|
<label class="form-label" for="regTableId">Table ID</label>
|
|
<input type="text" class="form-input" id="regTableId" readonly>
|
|
</div>
|
|
<div class="form-group">
|
|
<label class="form-label" for="regTableName">Table Name</label>
|
|
<input type="text" class="form-input" id="regTableName" readonly>
|
|
<div class="form-hint">Derived from the source table identifier</div>
|
|
</div>
|
|
<div class="form-group">
|
|
<label class="form-label" for="regStrategy">Sync Strategy</label>
|
|
<select class="form-select" id="regStrategy">
|
|
<option value="full_refresh">Full Refresh</option>
|
|
<option value="incremental">Incremental</option>
|
|
<option value="partitioned">Partitioned</option>
|
|
</select>
|
|
<div class="form-hint">How data should be synchronized from the source</div>
|
|
</div>
|
|
<div class="form-group">
|
|
<label class="form-label" for="regPrimaryKey">Primary Key</label>
|
|
<input type="text" class="form-input" id="regPrimaryKey" placeholder="e.g. id">
|
|
<div class="form-hint">Comma-separated list of primary key columns</div>
|
|
</div>
|
|
<div class="form-group">
|
|
<label class="form-label" for="regDescription">Description <span class="optional">(optional)</span></label>
|
|
<textarea class="form-textarea" id="regDescription" placeholder="Brief description of the table contents..."></textarea>
|
|
</div>
|
|
<div class="form-group">
|
|
<label class="form-label" for="regDataset">Dataset Group <span class="optional">(optional)</span></label>
|
|
<input type="text" class="form-input" id="regDataset" placeholder="e.g. crm, finance, marketing">
|
|
<div class="form-hint">Logical grouping for catalog organization</div>
|
|
</div>
|
|
</div>
|
|
<div class="modal-footer">
|
|
<button class="btn btn-secondary" onclick="closeRegisterModal()">Cancel</button>
|
|
<button class="btn btn-primary" id="registerSubmitBtn" onclick="registerTable()">
|
|
Register Table
|
|
</button>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<!-- ═══════════════ EDIT MODAL ═══════════════ -->
|
|
<div class="modal-overlay" id="editModal">
|
|
<div class="modal">
|
|
<div class="modal-header">
|
|
<h2>Edit Table</h2>
|
|
<button class="modal-close" onclick="closeEditModal()">
|
|
<svg width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
|
|
<line x1="18" y1="6" x2="6" y2="18"/>
|
|
<line x1="6" y1="6" x2="18" y2="18"/>
|
|
</svg>
|
|
</button>
|
|
</div>
|
|
<div class="modal-body">
|
|
<div class="form-group">
|
|
<label class="form-label" for="editTableId">Table ID</label>
|
|
<input type="text" class="form-input" id="editTableId" readonly>
|
|
</div>
|
|
<div class="form-group">
|
|
<label class="form-label" for="editStrategy">Sync Strategy</label>
|
|
<select class="form-select" id="editStrategy">
|
|
<option value="full_refresh">Full Refresh</option>
|
|
<option value="incremental">Incremental</option>
|
|
<option value="partitioned">Partitioned</option>
|
|
</select>
|
|
</div>
|
|
<div class="form-group">
|
|
<label class="form-label" for="editPrimaryKey">Primary Key</label>
|
|
<input type="text" class="form-input" id="editPrimaryKey" placeholder="e.g. id">
|
|
</div>
|
|
<div class="form-group">
|
|
<label class="form-label" for="editDescription">Description <span class="optional">(optional)</span></label>
|
|
<textarea class="form-textarea" id="editDescription" placeholder="Brief description of the table contents..."></textarea>
|
|
</div>
|
|
<div class="form-group">
|
|
<label class="form-label" for="editDataset">Dataset Group <span class="optional">(optional)</span></label>
|
|
<input type="text" class="form-input" id="editDataset" placeholder="e.g. crm, finance, marketing">
|
|
</div>
|
|
</div>
|
|
<div class="modal-footer">
|
|
<button class="btn btn-secondary" onclick="closeEditModal()">Cancel</button>
|
|
<button class="btn btn-primary" id="editSubmitBtn" onclick="saveTableEdit()">
|
|
Save Changes
|
|
</button>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<!-- ═══════════════ TOAST ═══════════════ -->
|
|
<div class="toast" id="toast">
|
|
<div class="toast-icon" id="toastIcon"></div>
|
|
<span id="toastMessage"></span>
|
|
</div>
|
|
|
|
<!-- ═══════════════ FOOTER ═══════════════ -->
|
|
<footer class="footer">
|
|
<a href="{{ url_for('dashboard') }}">Back to Dashboard</a>
|
|
</footer>
|
|
<script>
|
|
/* ═══════════════════════════════════════════════════════════════
|
|
Admin Tables - JavaScript
|
|
═══════════════════════════════════════════════════════════════ */
|
|
|
|
// State
|
|
let discoveryData = null;
|
|
let registryData = null;
|
|
let registryVersion = null;
|
|
let currentEditTableId = null;
|
|
|
|
// ── Toast notification ──────────────────────────────────────
|
|
|
|
function showToast(message, type) {
|
|
var toast = document.getElementById('toast');
|
|
var icon = document.getElementById('toastIcon');
|
|
var msg = document.getElementById('toastMessage');
|
|
|
|
toast.className = 'toast toast-' + type;
|
|
msg.textContent = message;
|
|
|
|
if (type === 'success') {
|
|
icon.innerHTML = '<svg width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="#10B77F" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M22 11.08V12a10 10 0 1 1-5.93-9.14"/><polyline points="22 4 12 14.01 9 11.01"/></svg>';
|
|
} else {
|
|
icon.innerHTML = '<svg width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="#EA580C" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><circle cx="12" cy="12" r="10"/><line x1="15" y1="9" x2="9" y2="15"/><line x1="9" y1="9" x2="15" y2="15"/></svg>';
|
|
}
|
|
|
|
// Show
|
|
requestAnimationFrame(function() {
|
|
toast.classList.add('visible');
|
|
});
|
|
|
|
// Hide after 4 seconds
|
|
setTimeout(function() {
|
|
toast.classList.remove('visible');
|
|
}, 4000);
|
|
}
|
|
|
|
// ── Format helpers ──────────────────────────────────────────
|
|
|
|
function formatNumber(n) {
|
|
if (n == null) return '-';
|
|
if (n >= 1000000) return (n / 1000000).toFixed(1) + 'M';
|
|
if (n >= 1000) return n.toLocaleString();
|
|
return String(n);
|
|
}
|
|
|
|
function formatSize(bytes) {
|
|
if (bytes == null || bytes === 0) return '-';
|
|
if (bytes >= 1073741824) return (bytes / 1073741824).toFixed(1) + ' GB';
|
|
if (bytes >= 1048576) return (bytes / 1048576).toFixed(1) + ' MB';
|
|
if (bytes >= 1024) return (bytes / 1024).toFixed(1) + ' KB';
|
|
return bytes + ' B';
|
|
}
|
|
|
|
function escapeHtml(str) {
|
|
if (!str) return '';
|
|
var div = document.createElement('div');
|
|
div.textContent = str;
|
|
return div.innerHTML;
|
|
}
|
|
|
|
// ── Discovery ───────────────────────────────────────────────
|
|
|
|
function discoverTables() {
|
|
var btn = document.getElementById('discoverBtn');
|
|
var resultsEl = document.getElementById('discoveryResults');
|
|
|
|
// Loading state
|
|
btn.disabled = true;
|
|
btn.innerHTML = '<span class="spinner"></span> Discovering...';
|
|
resultsEl.innerHTML = '<div class="loading-state"><div class="spinner spinner-lg"></div><span>Scanning data source for tables...</span></div>';
|
|
|
|
fetch('/api/admin/discover-tables')
|
|
.then(function(r) {
|
|
if (!r.ok) return r.json().then(function(d) { throw new Error(d.error || 'Discovery failed'); });
|
|
return r.json();
|
|
})
|
|
.then(function(data) {
|
|
discoveryData = data;
|
|
renderDiscoveryResults(data);
|
|
showToast('Found ' + data.total + ' tables in ' + data.buckets.length + ' buckets', 'success');
|
|
})
|
|
.catch(function(err) {
|
|
resultsEl.innerHTML = '<div class="panel-body-empty" style="color: var(--error);">Discovery failed: ' + escapeHtml(err.message) + '</div>';
|
|
showToast('Discovery failed: ' + err.message, 'error');
|
|
})
|
|
.finally(function() {
|
|
btn.disabled = false;
|
|
btn.innerHTML = '<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><circle cx="11" cy="11" r="8"/><line x1="21" y1="21" x2="16.65" y2="16.65"/></svg> Discover tables from source';
|
|
});
|
|
}
|
|
|
|
function renderDiscoveryResults(data) {
|
|
var el = document.getElementById('discoveryResults');
|
|
|
|
if (!data.buckets || data.buckets.length === 0) {
|
|
el.innerHTML = '<div class="panel-body-empty">No tables found in data source</div>';
|
|
return;
|
|
}
|
|
|
|
var html = '';
|
|
data.buckets.forEach(function(bucket) {
|
|
var registeredCount = bucket.tables.filter(function(t) { return t.is_registered; }).length;
|
|
|
|
html += '<div class="bucket-group">';
|
|
html += '<button class="bucket-trigger expanded" onclick="toggleBucket(this)">';
|
|
html += '<svg class="bucket-chevron" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><polyline points="9 18 15 12 9 6"/></svg>';
|
|
html += escapeHtml(bucket.bucket_name || bucket.bucket_id);
|
|
html += '<span class="bucket-count">' + bucket.tables.length + ' tables';
|
|
if (registeredCount > 0) html += ' / ' + registeredCount + ' registered';
|
|
html += '</span>';
|
|
html += '</button>';
|
|
html += '<div class="bucket-content expanded">';
|
|
|
|
bucket.tables.forEach(function(table) {
|
|
html += '<div class="table-item">';
|
|
html += '<div class="table-item-info">';
|
|
html += '<div class="table-item-name">' + escapeHtml(table.name) + '</div>';
|
|
html += '<div class="table-item-meta">';
|
|
if (table.columns != null) html += '<span>' + table.columns + ' columns</span>';
|
|
if (table.row_count != null) html += '<span>' + formatNumber(table.row_count) + ' rows</span>';
|
|
if (table.size_bytes != null) html += '<span>' + formatSize(table.size_bytes) + '</span>';
|
|
html += '</div>';
|
|
html += '</div>';
|
|
html += '<div class="table-item-actions">';
|
|
|
|
if (table.is_registered) {
|
|
html += '<span class="badge badge-registered">Registered</span>';
|
|
} else {
|
|
html += '<span class="badge badge-available">Available</span>';
|
|
html += '<button class="btn btn-primary btn-sm" onclick=\'openRegisterModal(' + JSON.stringify(table).replace(/'/g, "\\'") + ')\'>Register</button>';
|
|
}
|
|
|
|
html += '</div>';
|
|
html += '</div>';
|
|
});
|
|
|
|
html += '</div>';
|
|
html += '</div>';
|
|
});
|
|
|
|
el.innerHTML = html;
|
|
}
|
|
|
|
function toggleBucket(trigger) {
|
|
var content = trigger.nextElementSibling;
|
|
var isExpanded = trigger.classList.contains('expanded');
|
|
|
|
if (isExpanded) {
|
|
trigger.classList.remove('expanded');
|
|
content.classList.remove('expanded');
|
|
} else {
|
|
trigger.classList.add('expanded');
|
|
content.classList.add('expanded');
|
|
}
|
|
}
|
|
|
|
// ── Registration Modal ──────────────────────────────────────
|
|
|
|
function openRegisterModal(table) {
|
|
document.getElementById('regTableId').value = table.id || '';
|
|
document.getElementById('regTableName').value = table.name || '';
|
|
document.getElementById('regStrategy').value = 'full_refresh';
|
|
document.getElementById('regPrimaryKey').value = (table.primary_key || []).join(', ');
|
|
document.getElementById('regDescription').value = '';
|
|
document.getElementById('regDataset').value = '';
|
|
document.getElementById('registerSubmitBtn').disabled = false;
|
|
document.getElementById('registerModal').classList.add('active');
|
|
}
|
|
|
|
function closeRegisterModal() {
|
|
document.getElementById('registerModal').classList.remove('active');
|
|
}
|
|
|
|
function registerTable() {
|
|
var btn = document.getElementById('registerSubmitBtn');
|
|
btn.disabled = true;
|
|
btn.textContent = 'Registering...';
|
|
|
|
var pk = document.getElementById('regPrimaryKey').value.trim();
|
|
var primaryKey = pk ? pk.split(',').map(function(s) { return s.trim(); }).filter(Boolean) : [];
|
|
|
|
var payload = {
|
|
id: document.getElementById('regTableId').value,
|
|
name: document.getElementById('regTableName').value,
|
|
sync_strategy: document.getElementById('regStrategy').value,
|
|
primary_key: primaryKey,
|
|
description: document.getElementById('regDescription').value.trim(),
|
|
dataset: document.getElementById('regDataset').value.trim(),
|
|
version: registryVersion
|
|
};
|
|
|
|
fetch('/api/admin/register-table', {
|
|
method: 'POST',
|
|
headers: { 'Content-Type': 'application/json' },
|
|
body: JSON.stringify(payload)
|
|
})
|
|
.then(function(r) {
|
|
if (!r.ok) return r.json().then(function(d) { throw new Error(d.error || 'Registration failed'); });
|
|
return r.json();
|
|
})
|
|
.then(function(data) {
|
|
registryVersion = data.version;
|
|
closeRegisterModal();
|
|
showToast('Table registered successfully', 'success');
|
|
// Refresh both panels
|
|
loadRegistry();
|
|
if (discoveryData) discoverTables();
|
|
})
|
|
.catch(function(err) {
|
|
showToast('Registration failed: ' + err.message, 'error');
|
|
})
|
|
.finally(function() {
|
|
btn.disabled = false;
|
|
btn.textContent = 'Register Table';
|
|
});
|
|
}
|
|
|
|
// ── Edit Modal ──────────────────────────────────────────────
|
|
|
|
function openEditModal(table) {
|
|
currentEditTableId = table.id;
|
|
document.getElementById('editTableId').value = table.id || '';
|
|
document.getElementById('editStrategy').value = table.sync_strategy || 'full_refresh';
|
|
document.getElementById('editPrimaryKey').value = (table.primary_key || []).join(', ');
|
|
document.getElementById('editDescription').value = table.description || '';
|
|
document.getElementById('editDataset').value = table.dataset || '';
|
|
document.getElementById('editSubmitBtn').disabled = false;
|
|
document.getElementById('editModal').classList.add('active');
|
|
}
|
|
|
|
function closeEditModal() {
|
|
document.getElementById('editModal').classList.remove('active');
|
|
currentEditTableId = null;
|
|
}
|
|
|
|
function saveTableEdit() {
|
|
if (!currentEditTableId) return;
|
|
|
|
var btn = document.getElementById('editSubmitBtn');
|
|
btn.disabled = true;
|
|
btn.textContent = 'Saving...';
|
|
|
|
var pk = document.getElementById('editPrimaryKey').value.trim();
|
|
var primaryKey = pk ? pk.split(',').map(function(s) { return s.trim(); }).filter(Boolean) : [];
|
|
|
|
var payload = {
|
|
sync_strategy: document.getElementById('editStrategy').value,
|
|
primary_key: primaryKey,
|
|
description: document.getElementById('editDescription').value.trim(),
|
|
dataset: document.getElementById('editDataset').value.trim(),
|
|
version: registryVersion
|
|
};
|
|
|
|
fetch('/api/admin/registry/' + encodeURIComponent(currentEditTableId), {
|
|
method: 'PUT',
|
|
headers: { 'Content-Type': 'application/json' },
|
|
body: JSON.stringify(payload)
|
|
})
|
|
.then(function(r) {
|
|
if (!r.ok) return r.json().then(function(d) { throw new Error(d.error || 'Update failed'); });
|
|
return r.json();
|
|
})
|
|
.then(function(data) {
|
|
registryVersion = data.version;
|
|
closeEditModal();
|
|
showToast('Table updated successfully', 'success');
|
|
loadRegistry();
|
|
})
|
|
.catch(function(err) {
|
|
showToast('Update failed: ' + err.message, 'error');
|
|
})
|
|
.finally(function() {
|
|
btn.disabled = false;
|
|
btn.textContent = 'Save Changes';
|
|
});
|
|
}
|
|
|
|
// ── Registry ────────────────────────────────────────────────
|
|
|
|
function loadRegistry() {
|
|
var el = document.getElementById('registryContent');
|
|
el.innerHTML = '<div class="loading-state"><div class="spinner spinner-lg"></div><span>Loading registry...</span></div>';
|
|
|
|
fetch('/api/admin/registry')
|
|
.then(function(r) {
|
|
if (!r.ok) return r.json().then(function(d) { throw new Error(d.error || 'Load failed'); });
|
|
return r.json();
|
|
})
|
|
.then(function(data) {
|
|
registryData = data;
|
|
registryVersion = data.version;
|
|
renderRegistry(data);
|
|
})
|
|
.catch(function(err) {
|
|
el.innerHTML = '<div class="panel-body-empty" style="color: var(--error);">Failed to load registry: ' + escapeHtml(err.message) + '</div>';
|
|
});
|
|
}
|
|
|
|
function renderRegistry(data) {
|
|
var el = document.getElementById('registryContent');
|
|
var tables = data.tables || [];
|
|
var subtitle = document.getElementById('registrySubtitle');
|
|
|
|
subtitle.textContent = tables.length + ' table' + (tables.length !== 1 ? 's' : '') + ' configured for sync';
|
|
|
|
if (tables.length === 0) {
|
|
el.innerHTML = '<div class="panel-body-empty">No tables registered yet. Use the discovery panel above to find and register tables.</div>';
|
|
return;
|
|
}
|
|
|
|
var html = '<table class="registry-table">';
|
|
html += '<thead><tr>';
|
|
html += '<th>Table ID</th>';
|
|
html += '<th>Strategy</th>';
|
|
html += '<th>Primary Key</th>';
|
|
html += '<th>Description</th>';
|
|
html += '<th class="col-actions">Actions</th>';
|
|
html += '</tr></thead>';
|
|
html += '<tbody>';
|
|
|
|
tables.forEach(function(table) {
|
|
html += '<tr>';
|
|
html += '<td class="col-id" title="' + escapeHtml(table.id) + '">' + escapeHtml(table.id) + '</td>';
|
|
html += '<td class="col-strategy"><span class="strategy-badge">' + escapeHtml(table.sync_strategy || 'full_refresh') + '</span></td>';
|
|
html += '<td>' + escapeHtml((table.primary_key || []).join(', ') || '-') + '</td>';
|
|
html += '<td>' + escapeHtml(table.description || '-') + '</td>';
|
|
html += '<td class="col-actions">';
|
|
html += '<button class="btn-icon" title="Edit" onclick=\'openEditModal(' + JSON.stringify(table).replace(/'/g, "\\'") + ')\'>';
|
|
html += '<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M11 4H4a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2v-7"/><path d="M18.5 2.5a2.121 2.121 0 0 1 3 3L12 15l-4 1 1-4 9.5-9.5z"/></svg>';
|
|
html += '</button>';
|
|
html += '<button class="btn-icon danger" title="Delete" onclick="deleteTable(\'' + escapeHtml(table.id).replace(/'/g, "\\'") + '\')">';
|
|
html += '<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><polyline points="3 6 5 6 21 6"/><path d="M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6m3 0V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2"/></svg>';
|
|
html += '</button>';
|
|
html += '</td>';
|
|
html += '</tr>';
|
|
});
|
|
|
|
html += '</tbody></table>';
|
|
el.innerHTML = html;
|
|
}
|
|
|
|
function deleteTable(tableId) {
|
|
if (!confirm('Are you sure you want to unregister "' + tableId + '"?\n\nThis will remove it from sync and clean up user subscriptions.')) {
|
|
return;
|
|
}
|
|
|
|
fetch('/api/admin/registry/' + encodeURIComponent(tableId), {
|
|
method: 'DELETE',
|
|
headers: { 'Content-Type': 'application/json' },
|
|
body: JSON.stringify({ version: registryVersion })
|
|
})
|
|
.then(function(r) {
|
|
if (!r.ok) return r.json().then(function(d) { throw new Error(d.error || 'Delete failed'); });
|
|
return r.json();
|
|
})
|
|
.then(function(data) {
|
|
registryVersion = data.version;
|
|
showToast('Table unregistered successfully', 'success');
|
|
loadRegistry();
|
|
if (discoveryData) discoverTables();
|
|
})
|
|
.catch(function(err) {
|
|
showToast('Delete failed: ' + err.message, 'error');
|
|
});
|
|
}
|
|
|
|
// ── Modal close on overlay click ────────────────────────────
|
|
|
|
document.getElementById('registerModal').addEventListener('click', function(e) {
|
|
if (e.target === this) closeRegisterModal();
|
|
});
|
|
|
|
document.getElementById('editModal').addEventListener('click', function(e) {
|
|
if (e.target === this) closeEditModal();
|
|
});
|
|
|
|
// Close modals on Escape key
|
|
document.addEventListener('keydown', function(e) {
|
|
if (e.key === 'Escape') {
|
|
closeRegisterModal();
|
|
closeEditModal();
|
|
}
|
|
});
|
|
|
|
// ── Initialize ──────────────────────────────────────────────
|
|
|
|
loadRegistry();
|
|
|
|
</script>
|
|
{% include "_version_badge.html" %}
|
|
</body>
|
|
</html>
|