-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
133 additions
and
30 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
.aggrid-style-button { | ||
padding: 10px; | ||
background-color: #f8f8f8; | ||
color: #000000; | ||
font-family: var(--ag-font-family); | ||
font-size: 12px; | ||
font-weight: bold; | ||
border: 1px solid #babfc7; | ||
cursor: pointer; | ||
margin-bottom: 3px; | ||
margin-top: 2px; | ||
} | ||
|
||
.aggrid-style-button:hover { | ||
background-color: #dbdbdb; | ||
} | ||
|
||
.aggrid-style-button-disabled { | ||
opacity: 0.4; | ||
cursor: none; | ||
pointer-events: none; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
import { saveAs } from "file-saver"; | ||
|
||
import "./DownloadButton.css"; | ||
|
||
export const DownloadButton = ({ materialSelectorRef, disabled }) => { | ||
/* | ||
Note: the plan is to potentially also include direct download links (via the AiiDA rest api) | ||
to each of the materials in the downloaded file, but currently the index page doesn't have | ||
the structure UUIDs. Including them in the default index download is not great, as they would | ||
increase the initial download size considerably, while not really needed for the table. | ||
Therefore, it probably might make sense to implement an additional endpoint, e.g. pbe-v1/uuids | ||
that is only called when this download button is clicked. | ||
*/ | ||
|
||
const handleDownload = () => { | ||
if (materialSelectorRef.current) { | ||
const data = materialSelectorRef.current.getFilteredRows(); | ||
const json = JSON.stringify(data, null, 2); | ||
const blob = new Blob([json], { type: "application/json" }); | ||
const filename = `mc3d_index_data_n${data.length}.json`; | ||
saveAs(blob, filename); | ||
} | ||
}; | ||
|
||
return ( | ||
<button | ||
onClick={handleDownload} | ||
disabled={disabled} | ||
className={`aggrid-style-button ${disabled ? "aggrid-style-button-disabled" : ""}`} | ||
style={{ marginTop: "5px" }} | ||
> | ||
Download filtered entries | ||
</button> | ||
); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters