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

CSV Filterer

- - - -
- - - -
- -

Status: Unknown

- + +
+

CSV Filterer

+ +
+ + + +
+ +
+ + + +
+ +
+ + +
+ + + +
+ + + + 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 802bd48..acf1ce4 100644 --- a/mccs-it/CSVFilterer.js +++ b/mccs-it/CSVFilterer.js @@ -26,14 +26,14 @@ const users = new Map(); const enrollments = new Map(); let states = { - enrollments: "Unfiltered", - users: "Unparsed" + enrollments: false, + users: false } function filterEnrollments(document) { - let fileInput = document.getElementById('ueFileInput'); + let fileInput = document.getElementById('userEnrollmentsCsv'); let filterValue = "KV Instructor"; - document.getElementById('downloadLink') + document.getElementById('downloadBtn') if (!fileInput.files.length) { alert('Please select a CSV file.'); return; @@ -83,7 +83,6 @@ const parseUsers = (usersFileInputs, document) => { }); states.users = "Parsed"; refreshStatus(document); - generateList(document); }, error: function(error) { console.error(error); @@ -106,20 +105,27 @@ const generateList = (document) => { } const generateCSV = (input, document) => { - const downloadLink = document.getElementById("downloadLink"); - const csv = Papa.unparse(input); + const downloadLink = document.getElementById("downloadBtn"); - const blob = new Blob([csv], { type: 'text/csv' }); + const blob = new Blob([input], { type: 'text/csv' }); const url = URL.createObjectURL(blob); - downloadLink.href = url; - downloadLink.download = 'filtered.csv'; + downloadLink.onclick = `window.location = ${url}` downloadLink.style.display = 'block'; downloadLink.textContent = 'Download Filtered CSV'; } function refreshStatus(document) { - let statusSpan = document.getElementById('status') - let statusString = `Enrollments: ${states.enrollments} | Users: ${states.users}`; + let statusString = ""; + let statusSpan = document.getElementById('statusIndicator') + states.enrollments ? statusString += "Enrollments: Filtered" : statusString += "Enrollments: Not Filtered"; + states.users ? statusString += "
Users: Parsed" : statusString += "
Users: Not Parsed" statusSpan.innerHTML = statusString; + + if (states.enrollments && states.users) { + let refreshBtn = document.getElementById('refreshStatusBtn'); + let downloadBtn = document.getElementById('downloadBtn'); + refreshBtn.style = "display: none"; + downloadBtn.style = "display: block"; + } } \ No newline at end of file