{
+ setUploadClicked(false);
+ };
+
+ return (
+ <>
+
+ {uploadClicked && (
+
setUploadClicked(false)}
+ onResolve={handleSubmitUpload}
+ />
+ )}
+ >
+ );
+}
\ No newline at end of file
diff --git a/src/components/csv2aim/uploadcsv.jsx b/src/components/csv2aim/uploadcsv.jsx
new file mode 100644
index 000000000..9ddfe11fe
--- /dev/null
+++ b/src/components/csv2aim/uploadcsv.jsx
@@ -0,0 +1,121 @@
+import React from 'react';
+import PropTypes from 'prop-types';
+import { Modal, Button } from 'react-bootstrap';
+import { uploadCsv }from '../../services/annotationServices';
+import { getTemplates } from '../annotationsList/action';
+
+class UploadCSV extends React.Component {
+ mode = sessionStorage.getItem('mode');
+ state = {
+ tiff: false,
+ osirix: false,
+ projects: [],
+ files: [],
+ projectID: ''
+ };
+
+ onSelect = e => {
+ const { name, checked } = e.target;
+ this.setState({ [name]: checked });
+ };
+
+ onSelectFile = e => {
+ this.setState({ files: Array.from(e.target.files) });
+ };
+
+ onUpload = () => {
+ let {
+ clearTreeData,
+ onResolve,
+ onCancel,
+ onSubmit,
+ clearTreeExpand
+ } = this.props;
+
+ const promises = [];
+ const formData = new FormData();
+ this.state.files.forEach((file, index) => {
+ formData.append(`file${index + 1}`, file);
+ });
+ const config = {
+ headers: {
+ 'content-type': 'multipart/form-data'
+ }
+ };
+
+ if (onSubmit) onSubmit();
+ promises.push(uploadCsv(formData, config))
+
+ Promise.all(promises)
+ .then(() => {
+ if (clearTreeData) {
+ localStorage.setItem('treeData', JSON.stringify({}));
+ clearTreeExpand();
+ }
+ this.props.dispatch(getTemplates());
+ if (onResolve) onResolve();
+ })
+ .catch(err => {
+ console.error(err);
+ if (onResolve) onResolve();
+ });
+ onCancel();
+ this.setState({ projectID: '' });
+ };
+
+ selectProject = e => {
+ this.setState({ projectID: e.target.value });
+ };
+
+ renderUploadFileButton = () => {
+ return (
+
+ Select file:
+
+
+ );
+ };
+
+ render = () => {
+ let disabled = this.state.files.length === 0;
+ let className = 'alert-upload';
+ className = this.props.className
+ ? `${className} ${this.props.className}`
+ : className;
+ const { projects } = this.state;
+ return (
+
+
+ Upload CSV
+
+
+ {this.renderUploadFileButton()}
+
+
+
+
+
+
+ );
+ };
+}
+
+UploadCSV.propTypes = {
+ onCancel: PropTypes.func.isRequired,
+ clearTreeData: PropTypes.func,
+ onResolve: PropTypes.func,
+ onSubmit: PropTypes.func,
+ pid: PropTypes.string,
+ clearTreeExpand: PropTypes.func
+
+};
+
+export default UploadCSV;
diff --git a/src/services/annotationServices.js b/src/services/annotationServices.js
index 8c436efde..a73c451f7 100644
--- a/src/services/annotationServices.js
+++ b/src/services/annotationServices.js
@@ -205,3 +205,15 @@ export function uploadSegmentation(segmentation, segName, projectId = "lite") {
// };
// return http.post(url, segData, config);
// }
+
+export function uploadCsv(csvData, config) {
+ let url = http.apiUrl() + "/processCsv";
+// const aimData = new FormData();
+// aimData.append("file", csv);
+// const config = {
+// headers: {
+// "content-type": "multipart/form-data",
+// },
+// };
+ return http.post(url, csvData, config);
+}
\ No newline at end of file