diff --git a/src/components/deployment/UsePrebuiltProject/nghDemoPage.js b/src/components/deployment/UsePrebuiltProject/nghDemoPage.js index 80183d85..1738af67 100644 --- a/src/components/deployment/UsePrebuiltProject/nghDemoPage.js +++ b/src/components/deployment/UsePrebuiltProject/nghDemoPage.js @@ -56,7 +56,7 @@ class NGHDemoPage extends React.Component { $("#appbar-progress").progress({ percent: "0%" }); - }, 1000); + }, 1000); }); getDeployed(this.props.params.repoId).then(data => { this.setState({demoModel: JSON.parse(data)[0]}); diff --git a/src/components/inputcomponents/ImageInput/ImageInput.js b/src/components/inputcomponents/ImageInput/ImageInput.js index dd08a669..51f6c1f8 100644 --- a/src/components/inputcomponents/ImageInput/ImageInput.js +++ b/src/components/inputcomponents/ImageInput/ImageInput.js @@ -6,20 +6,24 @@ import toastr from 'toastr'; class ImageInput extends React.Component { constructor(props) { super(props); - this.formData = ''; + this.state = { + files: [] + }; this.sendRequest = this.sendRequest.bind(this); this.updateFormData = this.updateFormData.bind(this); } - componentDidMount() { - this.formData = new FormData($('#send-text')[0]); - } - shouldComponentUpdate() { return false; } sendRequest(sendAddr, calling_context) { + + let formData = new FormData($('#send-text')[0]); + this.state.files.map(file => { + formData.set(file.newfilename, file.newfile, file.newfilename); + }); + if (calling_context === "demo") { let timeout1 = ''; let timeout2 = ''; @@ -48,7 +52,7 @@ class ImageInput extends React.Component { $.ajax({ type: 'POST', url: sendAddr, - data: this.formData, + data: formData, contentType: false, cache: false, processData: false, @@ -70,7 +74,9 @@ class ImageInput extends React.Component { } updateFormData(newfile, newfilename) { - this.formData.set(newfilename, newfile, newfilename); + this.setState({ + files: [...this.state.files, {newfilename, newfile}] + }); } render() { diff --git a/src/components/inputcomponents/TextImageInput/TextImageInput.js b/src/components/inputcomponents/TextImageInput/TextImageInput.js index 50444083..e9120d81 100644 --- a/src/components/inputcomponents/TextImageInput/TextImageInput.js +++ b/src/components/inputcomponents/TextImageInput/TextImageInput.js @@ -6,19 +6,24 @@ import toastr from 'toastr'; class TextImageInput extends React.Component { constructor(props) { super(props); + this.state = { + files: [] + }; this.sendRequest = this.sendRequest.bind(this); this.updateFormData = this.updateFormData.bind(this); } - componentDidMount() { - this.formData = new FormData($('#send-text')[0]); - } - shouldComponentUpdate() { return false; } sendRequest(sendAddr, calling_context) { + + let formData = new FormData($('#send-text')[0]); + this.state.files.map(file => { + formData.set(file.newfilename, file.newfile, file.newfilename); + }); + if (calling_context === "demo") { let timeout1 = ''; let timeout2 = ''; @@ -47,7 +52,7 @@ class TextImageInput extends React.Component { $.ajax({ type: 'POST', url: sendAddr, - data: this.formData, + data: formData, contentType: false, cache: false, processData: false, @@ -78,7 +83,9 @@ class TextImageInput extends React.Component { } updateFormData(newfile, newfilename) { - this.formData.set(newfilename, newfile, newfilename); + this.setState({ + files: [...this.state.files, {newfilename, newfile}] + }); } render() { diff --git a/src/components/inputcomponents/TextInput/TextInput.js b/src/components/inputcomponents/TextInput/TextInput.js index 0dea282c..913f13c6 100644 --- a/src/components/inputcomponents/TextInput/TextInput.js +++ b/src/components/inputcomponents/TextInput/TextInput.js @@ -14,7 +14,9 @@ class TextInput extends React.Component { } sendRequest(sendAddr, calling_context) { + const form_data = new FormData($('#send-text')[0]); + if (calling_context === "demo") { let timeout1 = ''; let timeout2 = '';