chart_plugins
1 year ago
controllers
5 months ago
modules
9 months ago
utils
9 months ago
click-tracking-menu.js
1 year ago
dashboard_widget.js
2 years ago
download.js
1 year ago
index.js
5 months ago
layout.js
1 year ago
settings.js
1 year ago
download.js
24 lines
| 1 | function downloadCSV(fileName, data) { |
| 2 | const BOM = '\uFEFF' // UTF-8 byte-order mark (BOM) |
| 3 | const blob = new Blob([BOM + data], { type: 'text/csv;charset=utf-8' }) |
| 4 | |
| 5 | const element = window.document.createElement('a') |
| 6 | element.href = window.URL.createObjectURL(blob) |
| 7 | element.download = fileName |
| 8 | |
| 9 | document.body.appendChild(element) |
| 10 | element.click() |
| 11 | document.body.removeChild(element) |
| 12 | } |
| 13 | |
| 14 | function downloadJSON(fileName, data) { |
| 15 | const blob = new Blob([data], {type: 'application/json'}) |
| 16 | const element = window.document.createElement('a') |
| 17 | element.href = window.URL.createObjectURL(blob) |
| 18 | element.download = fileName |
| 19 | document.body.appendChild(element) |
| 20 | element.click() |
| 21 | document.body.removeChild(element) |
| 22 | } |
| 23 | |
| 24 | module.exports = {downloadCSV, downloadJSON} |