summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--client/faceSearch/faceSearch.actions.js10
-rw-r--r--client/faceSearch/faceSearch.container.js17
-rw-r--r--client/faceSearch/faceSearch.query.js3
-rw-r--r--client/util.js39
4 files changed, 13 insertions, 56 deletions
diff --git a/client/faceSearch/faceSearch.actions.js b/client/faceSearch/faceSearch.actions.js
index ccd51201..224977b5 100644
--- a/client/faceSearch/faceSearch.actions.js
+++ b/client/faceSearch/faceSearch.actions.js
@@ -40,16 +40,16 @@ export const updateOptions = opt => dispatch => {
// API functions
-export const upload = (file, query) => dispatch => {
+export const upload = (payload, file) => dispatch => {
// const { options } = store.getState().faceSearch
const tag = 'result'
const fd = new FormData()
fd.append('query_img', file)
// fd.append('limit', options.perPage)
- if (!query) {
- dispatch(loading(tag))
- }
- post(url.upload(), fd)
+ // if (!query) {
+ dispatch(loading(tag))
+ // }
+ post(url.upload(payload.dataset), fd)
.then(data => {
dispatch(loaded(tag, data))
})
diff --git a/client/faceSearch/faceSearch.container.js b/client/faceSearch/faceSearch.container.js
index e5fae24b..f96961db 100644
--- a/client/faceSearch/faceSearch.container.js
+++ b/client/faceSearch/faceSearch.container.js
@@ -9,23 +9,16 @@ import FaceSearchResult from './faceSearch.result'
class FaceSearchContainer extends Component {
render() {
+ const { payload } = this.props
+ console.log(payload)
return (
<div className='searchContainer'>
- <FaceSearchQuery />
- <FaceSearchResult />
+ <FaceSearchQuery payload={payload} />
+ <FaceSearchResult payload={payload} />
</div>
)
}
}
-const mapStateToProps = state => ({
- query: state.faceSearch.query,
- result: state.faceSearch.result,
- options: state.faceSearch.options,
-})
-const mapDispatchToProps = dispatch => ({
- actions: bindActionCreators({ ...actions }, dispatch),
-})
-
-export default connect(mapStateToProps, mapDispatchToProps)(FaceSearchContainer)
+export default FaceSearchContainer
diff --git a/client/faceSearch/faceSearch.query.js b/client/faceSearch/faceSearch.query.js
index 9313c538..1261269d 100644
--- a/client/faceSearch/faceSearch.query.js
+++ b/client/faceSearch/faceSearch.query.js
@@ -6,6 +6,7 @@ import * as actions from './faceSearch.actions'
class FaceSearchQuery extends Component {
upload(e) {
+ const { payload } = this.props
const files = e.dataTransfer ? e.dataTransfer.files : e.target.files
let i
let file
@@ -14,7 +15,7 @@ class FaceSearchQuery extends Component {
if (file && file.type.match('image.*')) break
}
if (!file) return
- this.props.actions.upload(file)
+ this.props.actions.upload(this.props.payload, file)
}
render() {
diff --git a/client/util.js b/client/util.js
index 4ce39ada..f181ad0f 100644
--- a/client/util.js
+++ b/client/util.js
@@ -40,10 +40,6 @@ export const pad = (n, m) => {
return s
}
-// Verified is 0/1 when retrieved from SQL, but 'verified' or 'unverified' when retrieved elsewhere
-export const isVerified = verified => verified === 1 || verified === '1' || verified === 'verified'
-export const verify = verified => isVerified(verified) ? 'verified' : 'unverified'
-
export const courtesyS = (n, s) => n + ' ' + (n === 1 ? s : s + 's')
export const padSeconds = n => n < 10 ? '0' + n : n
@@ -59,37 +55,11 @@ export const timestamp = (n = 0, fps = 25) => {
}
export const percent = n => (n * 100).toFixed(1) + '%'
-
export const px = (n, w) => Math.round(n * w) + 'px'
-
export const clamp = (n, a, b) => n < a ? a : n < b ? n : b
/* URLs */
-export const hashPath = sha256 => {
- if (!sha256 || sha256.length < 9) {
- throw new Error('Invalid sha256')
- }
- return [
- sha256.slice(0, 3),
- sha256.slice(3, 6),
- sha256.slice(6, 9),
- sha256,
- ].join('/')
-}
-
-export const imageUrl = (verified, sha256, frame, size = 'th') => [
- 'https://' + process.env.S3_HOST + '/v1/media/keyframes',
- isVerified(verified) ? null : 'unverified',
- hashPath(sha256),
- pad(frame, 6),
- size,
- 'index.jpg'
-].filter(s => !!s).join('/')
-
-export const metadataUri = (sha256, tag) => '/metadata/' + sha256 + '/' + tag + '/'
-export const keyframeUri = (sha256, frame) => '/metadata/' + sha256 + '/keyframe/' + pad(frame, 6) + '/'
-
export const preloadImage = opt => {
let { verified, hash, frame, url } = opt
if (hash && frame) {
@@ -112,11 +82,7 @@ export const preloadImage = opt => {
/* AJAX */
-let cachedAuth = null
-let token = ''
-let username = ''
-
-export const post = (uri, data, credentials) => {
+export const post = (uri, data) => {
let headers
if (data instanceof FormData) {
headers = {
@@ -135,9 +101,6 @@ export const post = (uri, data, credentials) => {
headers,
credentials: 'include',
}
- if (credentials) {
- headers.Authorization = 'Token ' + token
- }
// console.log(headers)
// headers['X-CSRFToken'] = csrftoken
return fetch(uri, opt).then(res => res.json())