Deadman922 commited on
Commit
ff42900
ยท
verified ยท
1 Parent(s): 54d5e0f

Upload index.html

Browse files
Files changed (1) hide show
  1. static/index.html +103 -17
static/index.html CHANGED
@@ -1444,28 +1444,48 @@ async function uploadDatabase() {
1444
  const data = await res.json();
1445
 
1446
  if (res.ok && data.status === 'ok') {
1447
- mode = 'custom';
1448
  customDbLoaded = true;
1449
  customDbSchema = data.tables;
1450
  customDbFilename = data.filename;
1451
  firstCustomTable = data.tables[0]?.table_name || 'table';
1452
 
1453
- // Update UI
1454
- document.getElementById('upload-status').innerHTML = 'โœ“ ' + data.filename + ' loaded (' + data.tables.length + ' tables)';
1455
- document.getElementById('upload-status').style.color = 'var(--success)';
1456
- document.getElementById('back-to-tasks-btn').style.display = 'inline-flex';
1457
-
1458
- // Update schema panel
1459
- renderSchema(data.tables);
1460
-
1461
- // Clear and set placeholder
1462
- document.getElementById('query-sql').value = '';
1463
- document.getElementById('query-sql').placeholder = 'SELECT * FROM ' + firstCustomTable + ' LIMIT 10';
1464
-
1465
- // Show custom mode UI
1466
- updateUIForMode();
1467
-
1468
- toast('Database uploaded successfully', 'success');
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1469
  } else {
1470
  document.getElementById('upload-error').style.display = 'block';
1471
  document.getElementById('upload-error').innerHTML = escapeHtml(data.detail || 'Upload failed');
@@ -1480,6 +1500,72 @@ async function uploadDatabase() {
1480
  setLoading('upload', false);
1481
  }
1482
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1483
  function backToTasks() {
1484
  mode = 'task';
1485
  customDbLoaded = false;
 
1444
  const data = await res.json();
1445
 
1446
  if (res.ok && data.status === 'ok') {
 
1447
  customDbLoaded = true;
1448
  customDbSchema = data.tables;
1449
  customDbFilename = data.filename;
1450
  firstCustomTable = data.tables[0]?.table_name || 'table';
1451
 
1452
+ // Store compatible tasks
1453
+ if (data.compatible_tasks && data.compatible_tasks.length > 0) {
1454
+ window.uploadedCompatibleTasks = data.compatible_tasks;
1455
+ window.usingUploadedDbForTasks = true;
1456
+
1457
+ // Enable task selection for uploaded DB
1458
+ mode = 'task'; // Stay in task mode, not custom mode
1459
+
1460
+ // Update UI
1461
+ document.getElementById('upload-status').innerHTML = 'โœ“ ' + data.filename + ' loaded (' + data.tables.length + ' tables) - <strong>' + data.compatible_tasks.length + ' tasks available</strong>';
1462
+ document.getElementById('upload-status').style.color = 'var(--success)';
1463
+ document.getElementById('back-to-tasks-btn').style.display = 'inline-flex';
1464
+
1465
+ // Update schema panel
1466
+ renderSchema(data.tables);
1467
+
1468
+ // Show task selection for uploaded DB
1469
+ showUploadedDbTaskSelector(data.compatible_tasks);
1470
+
1471
+ toast('Database uploaded! ' + data.compatible_tasks.length + ' tasks available', 'success');
1472
+ } else {
1473
+ // No compatible tasks - go to custom exploration mode
1474
+ mode = 'custom';
1475
+ window.uploadedCompatibleTasks = [];
1476
+ window.usingUploadedDbForTasks = false;
1477
+
1478
+ document.getElementById('upload-status').innerHTML = 'โœ“ ' + data.filename + ' loaded (' + data.tables.length + ' tables) - <em>No RL tasks compatible</em>';
1479
+ document.getElementById('upload-status').style.color = 'var(--text-secondary)';
1480
+ document.getElementById('back-to-tasks-btn').style.display = 'inline-flex';
1481
+
1482
+ renderSchema(data.tables);
1483
+ document.getElementById('query-sql').value = '';
1484
+ document.getElementById('query-sql').placeholder = 'SELECT * FROM ' + firstCustomTable + ' LIMIT 10';
1485
+ updateUIForMode();
1486
+
1487
+ toast('Database uploaded for exploration only (no compatible RL tasks)', 'success');
1488
+ }
1489
  } else {
1490
  document.getElementById('upload-error').style.display = 'block';
1491
  document.getElementById('upload-error').innerHTML = escapeHtml(data.detail || 'Upload failed');
 
1500
  setLoading('upload', false);
1501
  }
1502
 
1503
+ function showUploadedDbTaskSelector(compatibleTasks) {
1504
+ // Create or update task selector for uploaded DB
1505
+ let selector = document.getElementById('uploaded-db-task-selector');
1506
+ if (!selector) {
1507
+ selector = document.createElement('div');
1508
+ selector.id = 'uploaded-db-task-selector';
1509
+ selector.className = 'help-section';
1510
+ selector.style.cssText = 'background: #E8F5E9; border-color: #81C784; margin-top: 12px;';
1511
+ document.getElementById('upload-section').appendChild(selector);
1512
+ }
1513
+
1514
+ const taskLabels = {
1515
+ 'null_audit': 'Null Audit',
1516
+ 'type_repair': 'Type Repair',
1517
+ 'dedup_bug': 'Duplicate Bug',
1518
+ 'fk_integrity': 'FK Integrity',
1519
+ 'schema_drift': 'Schema Drift'
1520
+ };
1521
+
1522
+ let html = '<div style="font-size: 14px; color: #2E7D32; margin-bottom: 8px;"><strong>๐Ÿ“Š Select a Task to Run on Uploaded Database:</strong></div>';
1523
+ html += '<div style="display: flex; gap: 8px; flex-wrap: wrap;">';
1524
+
1525
+ compatibleTasks.forEach(taskId => {
1526
+ html += '<button class="btn btn-primary" onclick="selectUploadedDbTask(\'' + taskId + '\')" style="font-size: 12px; padding: 6px 12px;">' + taskLabels[taskId] + '</button>';
1527
+ });
1528
+
1529
+ html += '</div>';
1530
+ html += '<div style="margin-top: 8px; font-size: 11px; color: #558B2F;">These tasks will analyze your uploaded database</div>';
1531
+
1532
+ selector.innerHTML = html;
1533
+ selector.style.display = 'block';
1534
+ }
1535
+
1536
+ function selectUploadedDbTask(taskId) {
1537
+ // Update task selector to match
1538
+ document.getElementById('task-select').value = taskId;
1539
+ onTaskChange();
1540
+
1541
+ // Add indicator that we're using uploaded DB
1542
+ let indicator = document.getElementById('uploaded-db-indicator');
1543
+ if (!indicator) {
1544
+ indicator = document.createElement('div');
1545
+ indicator.id = 'uploaded-db-indicator';
1546
+ indicator.className = 'help-section';
1547
+ indicator.style.cssText = 'background: #FFF3E0; border-color: #FFB74D; margin-bottom: 12px;';
1548
+ document.querySelector('.main').insertBefore(indicator, document.querySelector('.main').firstChild);
1549
+ }
1550
+
1551
+ const taskLabels = {
1552
+ 'null_audit': 'Null Audit',
1553
+ 'type_repair': 'Type Repair',
1554
+ 'dedup_bug': 'Duplicate Bug',
1555
+ 'fk_integrity': 'FK Integrity',
1556
+ 'schema_drift': 'Schema Drift'
1557
+ };
1558
+
1559
+ indicator.innerHTML = '<div style="font-size: 13px; color: #E65100;"><strong>๐Ÿ—„๏ธ Running on Uploaded Database:</strong> ' + taskLabels[taskId] + ' task using your uploaded data</div>';
1560
+ indicator.style.display = 'block';
1561
+
1562
+ // Hide the task selector after selection
1563
+ const selector = document.getElementById('uploaded-db-task-selector');
1564
+ if (selector) selector.style.display = 'none';
1565
+
1566
+ toast('Task selected: ' + taskLabels[taskId] + ' (using uploaded DB)', 'success');
1567
+ }
1568
+
1569
  function backToTasks() {
1570
  mode = 'task';
1571
  customDbLoaded = false;