Add export as csv in tasks and workflow runs (#1361)
This commit is contained in:
21
skyvern-frontend/src/util/downloadBlob.ts
Normal file
21
skyvern-frontend/src/util/downloadBlob.ts
Normal file
@@ -0,0 +1,21 @@
|
||||
/**
|
||||
* Download contents as a file
|
||||
* Source: https://stackoverflow.com/questions/14964035/how-to-export-javascript-array-info-to-csv-on-client-side
|
||||
*/
|
||||
function downloadBlob(content: string, filename: string, contentType: string) {
|
||||
// Create a blob
|
||||
const blob = new Blob([content], { type: contentType });
|
||||
const url = URL.createObjectURL(blob);
|
||||
|
||||
// Create a link to download it
|
||||
const element = document.createElement("a");
|
||||
element.href = url;
|
||||
element.setAttribute("download", filename);
|
||||
element.style.display = "none";
|
||||
document.body.appendChild(element);
|
||||
element.click();
|
||||
document.body.removeChild(element);
|
||||
URL.revokeObjectURL(url);
|
||||
}
|
||||
|
||||
export { downloadBlob };
|
||||
Reference in New Issue
Block a user