Skip to content

Commit

Permalink
download button: replace href with detail_link that contains full url
Browse files Browse the repository at this point in the history
  • Loading branch information
eimrek committed Sep 3, 2024
1 parent 23bb77a commit 0ed3a62
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions src/MainPage/DownloadButton.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,19 @@ export const DownloadButton = ({ materialSelectorRef, disabled }) => {
const handleDownload = () => {
if (materialSelectorRef.current) {
const data = materialSelectorRef.current.getFilteredRows();
const json = JSON.stringify(data, null, 2);
// href currently just contains the url subpath to the detail page
// replace it with a better name and full url
let modData = data.map((entry) => {
let modEntry = {
...entry,
detail_link: `${window.location.origin}${entry.href}`,
};
delete modEntry.href;
return modEntry;
});
const json = JSON.stringify(modData, null, 2);
const blob = new Blob([json], { type: "application/json" });
const filename = `mc3d_index_data_n${data.length}.json`;
const filename = `mc3d_index_data_n${modData.length}.json`;
saveAs(blob, filename);
}
};
Expand Down

0 comments on commit 0ed3a62

Please sign in to comment.