diff --git a/mccs-it/CSVFilterer.html b/mccs-it/CSVFilterer.html index 169e187..a5a07a5 100644 --- a/mccs-it/CSVFilterer.html +++ b/mccs-it/CSVFilterer.html @@ -1,58 +1,60 @@ + + + + CSV Filterer + + + + - - - - CSV Filterer - - - - + +
+

CSV Filterer

- -
-

CSV Filterer

+
+ + + +
-
- - - +
+ + + +
+ +
+ + +
+ + + +
+ + + + Enrollments: Not Filtered
Users: Not Parsed +
+
+ +
- -
- - - -
- -
- - -
- - - -
- - - - Enrollments: Not Filtered
Users: Not Parsed -
-
-
- - - + + \ No newline at end of file diff --git a/mccs-it/CSVFilterer.js b/mccs-it/CSVFilterer.js index acf1ce4..1825ef4 100644 --- a/mccs-it/CSVFilterer.js +++ b/mccs-it/CSVFilterer.js @@ -56,6 +56,7 @@ function filterEnrollments(document) { states.enrollments = "Filtered"; refreshStatus(document); + console.log(JSON.stringify(enrollments)); }, error: function(error) { console.error(error); @@ -83,6 +84,7 @@ const parseUsers = (usersFileInputs, document) => { }); states.users = "Parsed"; refreshStatus(document); + console.log(users); }, error: function(error) { console.error(error); @@ -98,21 +100,28 @@ const generateList = (document) => { enrollments.forEach(e => { // Get the associated user const user = users.get(e.userId); - preCSV.push(`${user.userId},${e.timestamp}.${user.fName},${user.sName},${user.uName}`); + preCSV.push(`${user.userId},${e.timestamp},${user.fName},${user.sName},${user.uName}`); }); - - generateCSV(preCSV, document); + const postCSV = preCSV.join('\n'); + generateCSV(postCSV, document); } const generateCSV = (input, document) => { - const downloadLink = document.getElementById("downloadBtn"); + const downloadLink = document.getElementById("downloadLink"); const blob = new Blob([input], { type: 'text/csv' }); const url = URL.createObjectURL(blob); + console.log(url); + downloadLink.style = "display: inline;"; + downloadLink.href = url; + downloadLink.download = 'Instructors.CSV'; - downloadLink.onclick = `window.location = ${url}` - downloadLink.style.display = 'block'; - downloadLink.textContent = 'Download Filtered CSV'; + // downloadBtn.onclick = function() { + // const a = document.createElement('a'); + // a.href = url; + // a.download = 'data.csv'; + // document.body.appendChild(a); + // }; } function refreshStatus(document) {