Skip to content

Commit

Permalink
Add file download functionality for JSON/YAML tasks data
Browse files Browse the repository at this point in the history
Signed-off-by: shevijacobson <[email protected]>
  • Loading branch information
Shevijacobson committed Oct 28, 2024
1 parent 34e9a74 commit c4ec692
Showing 1 changed file with 14 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -215,6 +215,20 @@ export const ApplicationsTable: React.FC = () => {
selectedFormat === "yaml"
? yaml.dump(tasks, { indent: 2 })
: JSON.stringify(tasks, null, 2);

const blob = new Blob([data], {
type:
selectedFormat === "json" ? "application/json" : "application/x-yaml",
});
const url = URL.createObjectURL(blob);
const downloadLink = document.createElement("a"); // שינוי שם למשתנה
downloadLink.href = url;
downloadLink.download = `logs - ${ids}.${selectedFormat}`;
document.body.appendChild(downloadLink);
downloadLink.click();
document.body.removeChild(downloadLink);
URL.revokeObjectURL(url);

setIsDownloadModalOpen(false);
} catch (error) {
console.error("Error fetching tasks:", error);
Expand Down

0 comments on commit c4ec692

Please sign in to comment.