From 60e19825c2e8aef910b701bf2ca060d7fcbac78a Mon Sep 17 00:00:00 2001 From: Jules Laplace Date: Sat, 27 Apr 2019 20:30:25 +0200 Subject: multiple search results loading --- client/app.css | 39 +++++++++++++++++++++++++++++++++++++++ client/app.js | 18 ++++++++++++------ 2 files changed, 51 insertions(+), 6 deletions(-) create mode 100644 client/app.css (limited to 'client') diff --git a/client/app.css b/client/app.css new file mode 100644 index 0000000..a437c90 --- /dev/null +++ b/client/app.css @@ -0,0 +1,39 @@ +.query { + margin: 10px 0; +} +.query label { + display: flex; + flex-direction: row; +} +.query label span { + display: inline-block; + width: 100px; +} + +.results { + margin: 10px 0; + display: flex; + flex-direction: row; + flex-wrap: wrap; +} +.results .result { + width: 250px; + color: #333; +} +.results .result .img { + text-align: center; + height: 300px; +} +.results .result img { + max-width: 100%; + max-height: 300px; +} +.sha256 { + display: inline-block; + overflow: hidden; + white-space: pre; + max-width: 100%; +} +.results .result { + padding: 10px; +} \ No newline at end of file diff --git a/client/app.js b/client/app.js index b1c5eb4..7635162 100644 --- a/client/app.js +++ b/client/app.js @@ -3,6 +3,8 @@ import React, { Component } from 'react' import UploadImage from './lib/uploadImage.component' import { post } from './util' +import './app.css' + const initialState = { image: null, url: "", @@ -106,7 +108,7 @@ export default class PhashApp extends Component { ) } - const { success, error, match, matches } = res + const { success, error, match, results } = res if (!success) { return (
@@ -125,11 +127,15 @@ export default class PhashApp extends Component { return (
- {matches.map(({ phash, score, sha256, url }) => ( -
-
- Match: {sha256}
- Score: {score}
+ {results.map(({ phash, score, sha256, url }) => ( +
+
+
+ {score == 0 + ? Exact match + : Score: {score} + }
+ {sha256} Phash: {phash.toString(16)}
))} -- cgit v1.2.3-70-g09d2