Skip to content

Commit 74d0cd0

Browse files
author
Dylan Huang
committed
Add export functionality to EvaluationTable component
- Implemented a new feature to export filtered rows as a JSONL file. - Added a button to trigger the export, which is disabled when there are no rows to export. - Ensured the export includes a timestamp in the filename for better file management.
1 parent 8611cc6 commit 74d0cd0

File tree

1 file changed

+30
-0
lines changed

1 file changed

+30
-0
lines changed

vite-app/src/components/EvaluationTable.tsx

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,28 @@ export const EvaluationTable = observer(() => {
5555
state.handleSortFieldClick(field);
5656
};
5757

58+
const handleExportFilteredRows = () => {
59+
const rows = state.filteredOriginalDataset;
60+
61+
if (rows.length === 0) {
62+
return;
63+
}
64+
65+
const jsonlContent = rows.map((row) => JSON.stringify(row)).join("\n");
66+
const blob = new Blob([jsonlContent], {
67+
type: "application/x-ndjson",
68+
});
69+
const url = URL.createObjectURL(blob);
70+
const timestamp = new Date().toISOString().replace(/[.:]/g, "-");
71+
const link = document.createElement("a");
72+
link.href = url;
73+
link.download = `evaluation-rows-${timestamp}.jsonl`;
74+
document.body.appendChild(link);
75+
link.click();
76+
document.body.removeChild(link);
77+
URL.revokeObjectURL(url);
78+
};
79+
5880
return (
5981
<div className="bg-white border border-gray-200">
6082
{/* Filter Controls */}
@@ -104,6 +126,14 @@ export const EvaluationTable = observer(() => {
104126
<option value={100}>100</option>
105127
<option value={200}>200</option>
106128
</Select>
129+
<Button
130+
onClick={handleExportFilteredRows}
131+
size="sm"
132+
variant="primary"
133+
disabled={totalRows === 0}
134+
>
135+
Export JSONL
136+
</Button>
107137
</div>
108138
</div>
109139
<div className="flex items-center gap-2">

0 commit comments

Comments
 (0)