maybe progress?

This commit is contained in:
Martin Quarda 2024-10-07 12:01:29 +02:00
parent b7901de2f3
commit 99bde9edb9
2 changed files with 13 additions and 6 deletions

View File

@ -68,6 +68,7 @@
"react-image-gallery": "^1.3.0", "react-image-gallery": "^1.3.0",
"react-images": "1.0.0", "react-images": "1.0.0",
"react-photo-gallery": "^8.0.0", "react-photo-gallery": "^8.0.0",
"sass": "^1.70.0" "sass": "^1.70.0",
"axios": "^1.7.7"
} }
} }

View File

@ -6,6 +6,7 @@ import { render } from "react-dom";
import Gallery from "react-photo-gallery"; import Gallery from "react-photo-gallery";
import { Modal, ModalGateway } from "react-images"; import { Modal, ModalGateway } from "react-images";
import ImageGallery from "react-image-gallery"; import ImageGallery from "react-image-gallery";
import axios from 'axios';
const addr_prefix = "" //"http://localhost:8000" const addr_prefix = "" //"http://localhost:8000"
@ -25,6 +26,7 @@ class Main extends Component {
photoIsOpen: false, photoIsOpen: false,
progress: false, progress: false,
currentImage: 0, currentImage: 0,
uploadProgress: 0.0,
}; };
fetch(addr_prefix + "/api/results").then(resp => resp.json()).then(json => { fetch(addr_prefix + "/api/results").then(resp => resp.json()).then(json => {
this.setState({results: json}) this.setState({results: json})
@ -68,11 +70,15 @@ class Main extends Component {
return; return;
} }
this.setState({progress: true}) this.setState({progress: true})
fetch(addr_prefix + api_endpoint, { axios(
method:"POST", {
body: formData, method: 'post',
}).then(resp => resp.json()).then(json => { url: addr_prefix + api_endpoint,
this.setState({progress:false}) data: formData,
onUploadProgress: ({loaded, total}) => this.setState({uploadProgress: loaded/total})
}
).then(resp => resp.json()).then(json => {
this.setState({progress:false, uploadProgress: 1.0});
if(json.reason){ if(json.reason){
this.setState({ this.setState({
text: json.reason, text: json.reason,