Spaces:
Running
Running
remove table rendering
Browse files- index.html +3 -62
index.html
CHANGED
|
@@ -62,10 +62,6 @@
|
|
| 62 |
<div id="vizContainer" class="viz-container"></div>
|
| 63 |
</div>
|
| 64 |
|
| 65 |
-
<div id="resultsContainer" class="results-container" style="display: none;">
|
| 66 |
-
<h2>Results</h2>
|
| 67 |
-
<div id="results" class="results"></div>
|
| 68 |
-
</div>
|
| 69 |
</div>
|
| 70 |
|
| 71 |
<script type="module">
|
|
@@ -99,54 +95,6 @@
|
|
| 99 |
statusEl.style.display = 'block';
|
| 100 |
}
|
| 101 |
|
| 102 |
-
// Render results as HTML table
|
| 103 |
-
function renderResults(result) {
|
| 104 |
-
const resultsContainer = document.getElementById('resultsContainer');
|
| 105 |
-
const resultsEl = document.getElementById('results');
|
| 106 |
-
|
| 107 |
-
resultsContainer.style.display = 'block';
|
| 108 |
-
|
| 109 |
-
if (!result || result.numRows === 0) {
|
| 110 |
-
resultsEl.innerHTML = '<p class="no-results">No results found.</p>';
|
| 111 |
-
return;
|
| 112 |
-
}
|
| 113 |
-
|
| 114 |
-
// Get column names and rows
|
| 115 |
-
const columns = result.schema.fields.map(field => field.name);
|
| 116 |
-
const rows = result.toArray();
|
| 117 |
-
|
| 118 |
-
// Build HTML table
|
| 119 |
-
let tableHtml = '<div class="table-wrapper"><table><thead><tr>';
|
| 120 |
-
|
| 121 |
-
// Add headers
|
| 122 |
-
columns.forEach(col => {
|
| 123 |
-
tableHtml += `<th>${escapeHtml(col)}</th>`;
|
| 124 |
-
});
|
| 125 |
-
tableHtml += '</tr></thead><tbody>';
|
| 126 |
-
|
| 127 |
-
// Add rows
|
| 128 |
-
rows.forEach(row => {
|
| 129 |
-
tableHtml += '<tr>';
|
| 130 |
-
columns.forEach(col => {
|
| 131 |
-
const value = row[col];
|
| 132 |
-
tableHtml += `<td>${escapeHtml(String(value ?? ''))}</td>`;
|
| 133 |
-
});
|
| 134 |
-
tableHtml += '</tr>';
|
| 135 |
-
});
|
| 136 |
-
|
| 137 |
-
tableHtml += '</tbody></table></div>';
|
| 138 |
-
tableHtml += `<p class="row-count">Showing ${result.numRows} row(s)</p>`;
|
| 139 |
-
|
| 140 |
-
resultsEl.innerHTML = tableHtml;
|
| 141 |
-
}
|
| 142 |
-
|
| 143 |
-
// Escape HTML to prevent XSS
|
| 144 |
-
function escapeHtml(text) {
|
| 145 |
-
const div = document.createElement('div');
|
| 146 |
-
div.textContent = text;
|
| 147 |
-
return div.innerHTML;
|
| 148 |
-
}
|
| 149 |
-
|
| 150 |
// Determine if a DuckDB type is a complex type (struct, list, map, etc.)
|
| 151 |
function isComplexType(type) {
|
| 152 |
const complexTypes = ['STRUCT', 'LIST', 'MAP', 'UNION', 'ARRAY'];
|
|
@@ -411,20 +359,13 @@
|
|
| 411 |
}
|
| 412 |
catch {}
|
| 413 |
|
| 414 |
-
|
| 415 |
-
|
| 416 |
-
|
| 417 |
-
const result = await conn.query("SELECT * FROM 'data.parquet' LIMIT 1000");
|
| 418 |
-
|
| 419 |
-
setStatus('Data loaded successfully!', 'success');
|
| 420 |
-
|
| 421 |
-
// Render results
|
| 422 |
-
renderResults(result);
|
| 423 |
|
| 424 |
} catch (error) {
|
| 425 |
console.error('Error:', error);
|
| 426 |
setStatus(`Error: ${error.message}`, 'error');
|
| 427 |
-
document.getElementById('resultsContainer').style.display = 'none';
|
| 428 |
} finally {
|
| 429 |
submitBtn.disabled = false;
|
| 430 |
submitBtn.textContent = 'Load Dataset';
|
|
|
|
| 62 |
<div id="vizContainer" class="viz-container"></div>
|
| 63 |
</div>
|
| 64 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 65 |
</div>
|
| 66 |
|
| 67 |
<script type="module">
|
|
|
|
| 95 |
statusEl.style.display = 'block';
|
| 96 |
}
|
| 97 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 98 |
// Determine if a DuckDB type is a complex type (struct, list, map, etc.)
|
| 99 |
function isComplexType(type) {
|
| 100 |
const complexTypes = ['STRUCT', 'LIST', 'MAP', 'UNION', 'ARRAY'];
|
|
|
|
| 359 |
}
|
| 360 |
catch {}
|
| 361 |
|
| 362 |
+
// Detect columns and populate visualization dropdown
|
| 363 |
+
currentDatasetUrl = parquetUrl;
|
| 364 |
+
await detectColumns(parquetUrl);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 365 |
|
| 366 |
} catch (error) {
|
| 367 |
console.error('Error:', error);
|
| 368 |
setStatus(`Error: ${error.message}`, 'error');
|
|
|
|
| 369 |
} finally {
|
| 370 |
submitBtn.disabled = false;
|
| 371 |
submitBtn.textContent = 'Load Dataset';
|