Skip to content

Commit

Permalink
Add download CSV button
Browse files Browse the repository at this point in the history
  • Loading branch information
zMendes committed Sep 11, 2023
1 parent 0a9cfe1 commit 0ede9bb
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
14 changes: 14 additions & 0 deletions backend/app/dashboard/static/dashboard-progress.js
Original file line number Diff line number Diff line change
Expand Up @@ -264,6 +264,20 @@ function toggleVisibility() {
}
}

function downloadCSV() {
let exportPlugin2 = hot.getPlugin('exportFile');
let blob = exportPlugin2.exportAsBlob('csv', {
columnHeaders: true,
});

//is there a better way to do this?
let downloadLink = document.createElement('a');
downloadLink.href = URL.createObjectURL(blob);
downloadLink.download = 'exercise_data.csv';
downloadLink.click();

}

document.addEventListener('DOMContentLoaded', function () {

let active_button = document.getElementById("semester");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
</datalist>
</div>
<button onclick="toggleVisibility()" class="btn btn-secondary">Toggle visualization</button>
<button onclick="downloadCSV()" class="btn btn-secondary">Download CSV</button>
<div id="tags-list"></div>
{% endblock %}

Expand Down

0 comments on commit 0ede9bb

Please sign in to comment.