MVP
This commit is contained in:
parent
da26029330
commit
e374ef1677
@ -1,6 +1,5 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
@ -52,7 +51,10 @@
|
||||
Enrollments: Not Filtered<br />Users: Not Parsed
|
||||
</span>
|
||||
</div>
|
||||
|
||||
<div class="flex items-center justify-center space-x-4"" id="downloadLinkContainer">
|
||||
<a href="google.com" id="downloadLink" style="display: none;">Download CSV File</a>
|
||||
</div>
|
||||
</div>
|
||||
</body>
|
||||
|
||||
</html>
|
@ -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) {
|
||||
|
Loading…
Reference in New Issue
Block a user