Spaces:
Running
Running
Commit
·
5ad571f
1
Parent(s):
e3662c2
adding logic for download
Browse files- templates/data.html +19 -17
templates/data.html
CHANGED
|
@@ -93,23 +93,25 @@
|
|
| 93 |
|
| 94 |
// Function to handle the table data download
|
| 95 |
function downloadTableData() {
|
| 96 |
-
|
| 97 |
-
|
| 98 |
-
|
| 99 |
-
|
| 100 |
-
|
| 101 |
-
|
| 102 |
-
|
| 103 |
-
|
| 104 |
-
|
| 105 |
-
|
| 106 |
-
|
| 107 |
-
|
| 108 |
-
|
| 109 |
-
|
| 110 |
-
|
| 111 |
-
|
| 112 |
-
|
|
|
|
|
|
|
| 113 |
}
|
| 114 |
|
| 115 |
// ... rest of the existing code ...
|
|
|
|
| 93 |
|
| 94 |
// Function to handle the table data download
|
| 95 |
function downloadTableData() {
|
| 96 |
+
const selectedTable = $('#table-dropdown').val();
|
| 97 |
+
if (selectedTable) {
|
| 98 |
+
const fileName = `referencefiles/${selectedTable}.csv`;
|
| 99 |
+
fetch(fileName)
|
| 100 |
+
.then(response => response.blob())
|
| 101 |
+
.then(blob => {
|
| 102 |
+
const url = window.URL.createObjectURL(blob);
|
| 103 |
+
const a = document.createElement('a');
|
| 104 |
+
a.style.display = 'none';
|
| 105 |
+
a.href = url;
|
| 106 |
+
a.download = `${selectedTable}.csv`;
|
| 107 |
+
document.body.appendChild(a);
|
| 108 |
+
a.click();
|
| 109 |
+
window.URL.revokeObjectURL(url);
|
| 110 |
+
})
|
| 111 |
+
.catch(error => console.error('Error downloading the file:', error));
|
| 112 |
+
} else {
|
| 113 |
+
alert('Please select a table to download.');
|
| 114 |
+
}
|
| 115 |
}
|
| 116 |
|
| 117 |
// ... rest of the existing code ...
|