Skip to content

Commit 753f5a3

Browse files
Merge pull request #1 from yianzhang14/main
add upload
2 parents 270e80b + 773354e commit 753f5a3

File tree

1 file changed

+23
-0
lines changed

1 file changed

+23
-0
lines changed

src/App.tsx

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,12 @@ function App() {
7171
const [submissionResponse, setSubmissionResponse] = useState<string>('');
7272
const [jobFinished, setJobFinished] = useState<string>('');
7373
const [jobOutput, setJobOutput] = useState<string>('');
74+
const [file, setFile] = useState<File | null>(null);
75+
76+
const handleFileChange = (event: ChangeEvent<HTMLInputElement>) => {
77+
const selectedFile = event.target.files?.[0] || null;
78+
setFile(selectedFile);
79+
};
7480

7581
// Code to load data from flask backend at start
7682
useEffect(() => {
@@ -214,6 +220,18 @@ function App() {
214220
.then(err => {console.log(err); return null});
215221
console.log("New job ID is:", jobID);
216222

223+
if (file !== null) {
224+
const formData = new FormData()
225+
formData.append("jupyterhubApiToken", token_dict["jupyterhubApiToken"]);
226+
formData.append("jobId", jobID);
227+
formData.append("file", file);
228+
// upload
229+
await fetch('https://cgjobsup-test.cigi.illinois.edu/v2/upload', {
230+
method: "POST",
231+
body: formData
232+
});
233+
}
234+
217235
// set the job parameters
218236
await fetch('https://cgjobsup-test.cigi.illinois.edu/v2/job/' + jobID,
219237
{
@@ -428,6 +446,11 @@ function App() {
428446
</AccordionPanel>
429447
</AccordionItem>
430448
</Accordion>
449+
<input
450+
type="file"
451+
id="upload"
452+
onChange={handleFileChange}
453+
/>
431454
<Box className="mt-4">
432455
<Checkbox>Receive email on job status? (Not implemented yet)</Checkbox>
433456
<Input placeholder="example@illinois.edu" className="mt-2"/>

0 commit comments

Comments
 (0)