-
Notifications
You must be signed in to change notification settings - Fork 0
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
1 parent
6591597
commit d54c57a
Showing
7 changed files
with
115 additions
and
97 deletions.
There are no files selected for viewing
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
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 |
---|---|---|
@@ -1,82 +1,84 @@ | ||
import React, { useRef } from 'react'; | ||
import React, { useRef } from "react"; | ||
import { Container, Row, Col, Button } from "react-bootstrap"; | ||
import { useAnnotationStore } from '../stores/AnnotationStore'; | ||
import { useAnnotationStore } from "../stores/AnnotationStore"; | ||
|
||
const OutputContainer = () => { | ||
|
||
const inputFile = useRef() | ||
|
||
const annotationStore = useAnnotationStore() | ||
const inputFile = useRef(); | ||
const annotationStore = useAnnotationStore(); | ||
const outputJSON = JSON.stringify(annotationStore.outputAnnotation); | ||
|
||
const openFile = (e) => { | ||
const fileObj = e.target.files[0]; | ||
const reader = new FileReader(); | ||
const reader = new FileReader(); | ||
reader.onload = (e) => { | ||
const fileContents = e.target.result; | ||
annotationStore.setAnnotationsFromFile(JSON.parse(fileContents)) | ||
} | ||
annotationStore.setAnnotationsFromFile(JSON.parse(fileContents)); | ||
}; | ||
if (fileObj) reader.readAsText(fileObj); | ||
else return | ||
} | ||
else return; | ||
}; | ||
|
||
const upload = (e) => { | ||
e.preventDefault(); | ||
inputFile.current.click() | ||
} | ||
|
||
return ( | ||
<Container fluid="md" className="mt-2"> | ||
<Row className="section-wrapper justify-content-center"> | ||
<Col md="10"> | ||
<div className="output"> | ||
<code>Output: </code> | ||
<br/> | ||
<code>{outputJSON}</code> | ||
</div> | ||
</Col> | ||
<Col md="2" className="align-items-center"> | ||
<Row className="text-center mt-2"> | ||
<Button size="sm" variant="light">Edit</Button>{" "} | ||
</Row> | ||
<hr/> | ||
<Row className="text-center mt-2"> | ||
<h5>Annotations</h5> | ||
<Col> | ||
<Button | ||
size="sm" | ||
variant="success" | ||
href={`data:text/json;charset=utf-8,${encodeURIComponent( JSON.stringify(annotationStore.outputAnnotation, null, 4))}`} | ||
download="3Dannotation.json" | ||
> | ||
Download | ||
</Button> | ||
</Col> | ||
<Col> | ||
<Button | ||
size="sm" | ||
variant="primary" | ||
className="px-3" | ||
onClick={upload} | ||
> | ||
Upload | ||
</Button> | ||
e.preventDefault(); | ||
inputFile.current.click(); | ||
}; | ||
|
||
<input | ||
type="file" | ||
name="file" | ||
ref={inputFile} | ||
style={{display: "none"}} | ||
multiple={false} | ||
accept=".json,application/json" | ||
onChange={openFile} /> | ||
return ( | ||
<Container fluid="md" className="mt-2"> | ||
<Row className="section-wrapper justify-content-center"> | ||
<Col md="10"> | ||
<div className="output"> | ||
<code>Output: </code> | ||
<br /> | ||
<code>{outputJSON}</code> | ||
</div> | ||
</Col> | ||
<Col md="2" className="align-items-center"> | ||
<Row className="text-center mt-2"> | ||
<Button size="sm" variant="light"> | ||
Edit | ||
</Button>{" "} | ||
</Row> | ||
<hr /> | ||
<Row className="text-center mt-2"> | ||
<h5>Annotations</h5> | ||
<Col> | ||
<Button | ||
size="sm" | ||
variant="success" | ||
href={`data:text/json;charset=utf-8,${encodeURIComponent( | ||
JSON.stringify(annotationStore.outputAnnotation, null, 4) | ||
)}`} | ||
download="3Dannotation.json" | ||
> | ||
Download | ||
</Button> | ||
</Col> | ||
<Col> | ||
<Button | ||
size="sm" | ||
variant="primary" | ||
className="px-3" | ||
onClick={upload} | ||
> | ||
Upload | ||
</Button> | ||
|
||
</Col> | ||
</Row> | ||
</Col> | ||
</Row> | ||
</Container> | ||
) | ||
} | ||
<input | ||
type="file" | ||
name="file" | ||
ref={inputFile} | ||
style={{ display: "none" }} | ||
multiple={false} | ||
accept=".json,application/json" | ||
onChange={openFile} | ||
/> | ||
</Col> | ||
</Row> | ||
</Col> | ||
</Row> | ||
</Container> | ||
); | ||
}; | ||
|
||
export default OutputContainer | ||
export default OutputContainer; |
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
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 |
---|---|---|
@@ -1,3 +1,4 @@ | ||
|
||
const getFixedNumber = (number, digits) => | ||
Math.round(number * 10 ** digits) / 10 ** digits; | ||
|
||
|