Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

fix: attempt at fixing CSV exports crashing aw-android #532

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 17 additions & 8 deletions src/views/Buckets.vue
Original file line number Diff line number Diff line change
Expand Up @@ -267,16 +267,25 @@ export default {
);
});
const csv = Papa.unparse(data, { columns, header: true });
const blob = new Blob([csv], { type: 'text/csv' });
const url = URL.createObjectURL(blob);
const link = document.createElement('a');
link.href = url;
link.download = `aw-events-export-${bucketId}-${new Date()
const filename = `aw-events-export-${bucketId}-${new Date()
.toISOString()
.substring(0, 10)}.csv`;
document.body.appendChild(link);
link.click();
document.body.removeChild(link);

// Check if the Android interface is available
if (window.Android) {
// Send the CSV data to the Android code
window.Android.downloadCSV(csv, filename);
} else {
// Fall back to the original method
const blob = new Blob([csv], { type: 'text/csv' });
const url = URL.createObjectURL(blob);
const link = document.createElement('a');
link.href = url;
link.download = filename;
document.body.appendChild(link);
link.click();
document.body.removeChild(link);
}
},
},
};
Expand Down