(endpoint, filename, data = {}, jsonifyData = false)
| 230 | } |
| 231 | |
| 232 | function downloadReport(endpoint, filename, data = {}, jsonifyData = false) { |
| 233 | function downloadObjectAsJson(data) { |
| 234 | stream('Downloading report: ' + filename); |
| 235 | const parsedData = jsonifyData ? JSON.stringify(data, null, 2) : data; |
| 236 | let dataStr = "data:text/json;charset=utf-8," + encodeURIComponent(parsedData); |
| 237 | let downloadAnchorNode = document.createElement('a'); |
| 238 | downloadAnchorNode.setAttribute("href", dataStr); |
| 239 | downloadAnchorNode.setAttribute("download", filename + ".json"); |
| 240 | document.body.appendChild(downloadAnchorNode); |
| 241 | downloadAnchorNode.click(); |
| 242 | downloadAnchorNode.remove(); |
| 243 | } |
| 244 | |
| 245 | restRequest('POST', data, downloadObjectAsJson, endpoint); |
| 246 | } |
| 247 | |
| 248 | function sleep(ms) { |
| 249 | return new Promise((resolve) => setTimeout(resolve, ms)); |
nothing calls this directly
no test coverage detected