Skip to content

Commit

Permalink
feat: only try one download case for the csv
Browse files Browse the repository at this point in the history
  • Loading branch information
sgrund14 committed Jan 9, 2021
1 parent bfb00c8 commit 5fc7055
Showing 1 changed file with 32 additions and 23 deletions.
55 changes: 32 additions & 23 deletions src/public/plugins/helpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,29 +10,38 @@ export function downloadCSV({ content, fileName }) {
const a = document.createElement('a')
const mimeType = 'text/csv;encoding:utf-8'

if (navigator.msSaveBlob) {
// IE10
navigator.msSaveBlob(
new Blob([content], {
type: mimeType,
}),
fileName
)
} else if (URL && 'download' in a) {
// html5 A[download]
a.href = URL.createObjectURL(
new Blob([content], {
type: mimeType,
})
)
a.setAttribute('download', fileName)
document.body.appendChild(a)
a.click()
document.body.removeChild(a)
} else {
location.href =
'data:application/octet-stream,' + encodeURIComponent(content) // only this mime type is supported
}
a.href = URL.createObjectURL(
new Blob([content], {
type: mimeType,
})
)
a.setAttribute('download', fileName)
document.body.appendChild(a)
a.click()
document.body.removeChild(a)

// if (navigator.msSaveBlob) {
// // IE10
// navigator.msSaveBlob(
// new Blob([content], {
// type: mimeType,
// }),
// fileName
// )
// } else if (URL && ('download' in a || a.download !== undefined)) {
// // html5 A[download]
// a.href = URL.createObjectURL(
// new Blob([content], {
// type: mimeType,
// })
// )
// a.setAttribute('download', fileName)
// document.body.appendChild(a)
// a.click()
// document.body.removeChild(a)
// } else {
// location.href = 'data:text/csv;charset=utf-8,' + encodeURIComponent(content)
// }
}

// function generateBins({ min, max }) {
Expand Down

0 comments on commit 5fc7055

Please sign in to comment.