From 0ede9bbed705c7b3b4ecdd06c260046f671d3948 Mon Sep 17 00:00:00 2001 From: zMendes Date: Mon, 11 Sep 2023 15:05:38 -0300 Subject: [PATCH] Add download CSV button --- backend/app/dashboard/static/dashboard-progress.js | 14 ++++++++++++++ .../templates/dashboard/instructor-progress.html | 1 + 2 files changed, 15 insertions(+) diff --git a/backend/app/dashboard/static/dashboard-progress.js b/backend/app/dashboard/static/dashboard-progress.js index 9d7336a..55ae37c 100644 --- a/backend/app/dashboard/static/dashboard-progress.js +++ b/backend/app/dashboard/static/dashboard-progress.js @@ -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"); diff --git a/backend/app/dashboard/templates/dashboard/instructor-progress.html b/backend/app/dashboard/templates/dashboard/instructor-progress.html index d4619e9..e6ad4fc 100644 --- a/backend/app/dashboard/templates/dashboard/instructor-progress.html +++ b/backend/app/dashboard/templates/dashboard/instructor-progress.html @@ -17,6 +17,7 @@ +
{% endblock %}