From a313f42b12fd58ae2db4561454c91eaf3b776c42 Mon Sep 17 00:00:00 2001 From: Jules Laplace Date: Sun, 28 Apr 2019 16:20:29 +0200 Subject: stuff working --- client/components/query.component.js | 87 +++++++++++++++++++++++------------- 1 file changed, 55 insertions(+), 32 deletions(-) (limited to 'client/components/query.component.js') diff --git a/client/components/query.component.js b/client/components/query.component.js index bd98ce8..715ea92 100644 --- a/client/components/query.component.js +++ b/client/components/query.component.js @@ -5,12 +5,15 @@ import { connect } from 'react-redux' import * as actions from '../actions' import UploadImage from './uploadImage.component' + class Query extends Component { state = { image: null, blob: null, url: "", threshold: 20, + searchType: 'file', + thresholdChanged: false, } handleUpload(blob) { @@ -19,14 +22,14 @@ class Query extends Component { URL.revokeObjectURL(image) } const url = URL.createObjectURL(blob) - this.setState({ image: url, blob }) + this.setState({ image: url, blob, thresholdChanged: false }) this.props.actions.upload(blob, threshold) } handleURL() { const { url, threshold } = this.state if (!url || url.indexOf('http') !== 0) return - this.setState({ image: url, blob: null }) + this.setState({ image: url, blob: null, thresholdChanged: false }) this.props.actions.submit(url, threshold) } @@ -40,62 +43,82 @@ class Query extends Component { } render() { - const { url, image, threshold } = this.state + const { url, image, threshold, thresholdChanged, searchType } = this.state const style = {} if (image) { - style.maxWidth = 200 - style.maxHeight = 200 style.backgroundImage = 'url(' + image + ')' - style.backgroundSize = 'cover' - style.opacity = 1 } return (
- - {/* - - */} +
+ Search by + + +
+ {searchType === 'file' + ? + : + } - {image &&
} + {image && +
+ Query image +
+
+ }
) } } -const mapStateToProps = state => ({ - ...state.api, -}) +const mapStateToProps = state => ({}) const mapDispatchToProps = dispatch => ({ actions: bindActionCreators({ ...actions }, dispatch), }) -- cgit v1.2.3-70-g09d2