@nyris/nyris-webapp 0.3.6 → 0.3.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build/asset-manifest.json +11 -11
- package/build/index.html +1 -1
- package/build/{precache-manifest.bffed513ca17d8ac16af1cc3aaa7d908.js → precache-manifest.a97813497ab8d37548141e5e2618d0dc.js} +9 -9
- package/build/service-worker.js +1 -1
- package/build/static/css/{main.2a76dc8a.chunk.css → main.0481043c.chunk.css} +2 -2
- package/build/static/css/main.0481043c.chunk.css.map +1 -0
- package/build/static/js/2.6e13adbe.chunk.js +3 -0
- package/build/static/js/{2.4e9a4ce1.chunk.js.LICENSE.txt → 2.6e13adbe.chunk.js.LICENSE.txt} +0 -0
- package/build/static/js/{2.4e9a4ce1.chunk.js.map → 2.6e13adbe.chunk.js.map} +1 -1
- package/build/static/js/main.f5da7aa4.chunk.js +2 -0
- package/build/static/js/main.f5da7aa4.chunk.js.map +1 -0
- package/package.json +2 -2
- package/src/App.tsx +83 -95
- package/src/actions/searchActions.ts +3 -4
- package/src/components/FiltersList.tsx +16 -18
- package/src/components/Sidebar.tsx +6 -4
- package/src/epics/search.ts +2 -41
- package/src/index.css +3 -3
- package/src/index.tsx +5 -3
- package/build/static/css/main.2a76dc8a.chunk.css.map +0 -1
- package/build/static/js/2.4e9a4ce1.chunk.js +0 -3
- package/build/static/js/main.ec93aa4d.chunk.js +0 -2
- package/build/static/js/main.ec93aa4d.chunk.js.map +0 -1
- package/src/Demo2.tsx +0 -220
package/src/Demo2.tsx
DELETED
|
@@ -1,220 +0,0 @@
|
|
|
1
|
-
import React, { useEffect, useState } from "react";
|
|
2
|
-
import { useDispatch } from "react-redux";
|
|
3
|
-
import { Animate, NodeGroup } from "react-move";
|
|
4
|
-
import { useDropzone} from "react-dropzone";
|
|
5
|
-
import {
|
|
6
|
-
Box,
|
|
7
|
-
Snackbar
|
|
8
|
-
} from "@material-ui/core";
|
|
9
|
-
import { Alert } from "@material-ui/lab";
|
|
10
|
-
import classNames from "classnames";
|
|
11
|
-
import { loadFilters } from "./actions/searchActions";
|
|
12
|
-
import {AppProps} from "./App";
|
|
13
|
-
import Result from "./components/Result";
|
|
14
|
-
import Sidebar from "./components/Sidebar";
|
|
15
|
-
import Header from "./components/Header";
|
|
16
|
-
import Feedback from "./components/Feedback";
|
|
17
|
-
import CategoryFilter from "./components/CategoryFilter";
|
|
18
|
-
import Codes from "./components/Codes";
|
|
19
|
-
import PredictedCategories from "./components/PredictedCategories";
|
|
20
|
-
import ExampleImages from "./components/ExampleImages";
|
|
21
|
-
import {makeFileHandler, Capture, Preview} from "@nyris/nyris-react-components";
|
|
22
|
-
import { RectCoords, cadExtensions} from "@nyris/nyris-api";
|
|
23
|
-
|
|
24
|
-
export interface AppHandlers {
|
|
25
|
-
onExampleImageClick: (url: string) => void,
|
|
26
|
-
onImageClick: (position: number, url: string) => void,
|
|
27
|
-
onLinkClick: (position: number, url: string) => void,
|
|
28
|
-
onFileDropped: (file: File) => void,
|
|
29
|
-
onCaptureComplete: (image: HTMLCanvasElement) => void,
|
|
30
|
-
onCaptureCanceled: () => void,
|
|
31
|
-
onSelectFile: (f: File) => void,
|
|
32
|
-
onCameraClick: () => void,
|
|
33
|
-
onShowStart: () => void,
|
|
34
|
-
onSelectionChange: (r: RectCoords) => void,
|
|
35
|
-
onPositiveFeedback: () => void,
|
|
36
|
-
onNegativeFeedback: () => void,
|
|
37
|
-
onCloseFeedback: () => void
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
const Demo2: React.FC<AppProps> = ({
|
|
41
|
-
search: {results, regions, previewSelection, requestId, duration, errorMessage, filterOptions, categoryPredictions, codes, toastErrorMessage, filters},
|
|
42
|
-
showPart, settings, handlers, loading, previewImage, feedbackState
|
|
43
|
-
}) => {
|
|
44
|
-
|
|
45
|
-
const {getRootProps, getInputProps, isDragActive} = useDropzone({onDrop: (fs: File[]) => handlers.onFileDropped(fs[0])});
|
|
46
|
-
|
|
47
|
-
const minPreviewHeight = 400;
|
|
48
|
-
const halfOfTheScreenHeight = Math.floor(window.innerHeight * 0.45);
|
|
49
|
-
const maxPreviewHeight = Math.max(minPreviewHeight, halfOfTheScreenHeight);
|
|
50
|
-
const [toastOpen, setToastOpen] = useState(false);
|
|
51
|
-
const dispatch = useDispatch();
|
|
52
|
-
|
|
53
|
-
const acceptTypes =[ 'image/*' ].concat( settings.cadSearch ? cadExtensions : [] ).join(',');
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
useEffect(() => {
|
|
57
|
-
if (toastErrorMessage !== '') {
|
|
58
|
-
setToastOpen(true);
|
|
59
|
-
}
|
|
60
|
-
}, [toastErrorMessage])
|
|
61
|
-
|
|
62
|
-
useEffect(() =>{
|
|
63
|
-
dispatch(loadFilters());
|
|
64
|
-
}, [dispatch])
|
|
65
|
-
|
|
66
|
-
return (
|
|
67
|
-
<React.Fragment>
|
|
68
|
-
<Header/>
|
|
69
|
-
<div className="wrapperBody">
|
|
70
|
-
<Sidebar filters={filters}/>
|
|
71
|
-
|
|
72
|
-
<div className="mainContent">
|
|
73
|
-
{showPart === 'camera' &&
|
|
74
|
-
<Capture onCaptureComplete={handlers.onCaptureComplete} onCaptureCanceled={handlers.onCaptureCanceled}
|
|
75
|
-
useAppText='Use default camera app'/>}
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
<div className={classNames('headSection', {hidden: showPart === 'results'})} id="headSection">
|
|
79
|
-
<div {...getRootProps({
|
|
80
|
-
onClick: e => {
|
|
81
|
-
e.stopPropagation();
|
|
82
|
-
}
|
|
83
|
-
})} className={classNames('wrapper', 'dragAndDropActionArea', {'fileIsHover': isDragActive})}>
|
|
84
|
-
|
|
85
|
-
<div className={classNames('contentWrap')}>
|
|
86
|
-
<Box display="flex" flexDirection="column" justifyContent="center" alignItems="center" minHeight="100vh">
|
|
87
|
-
<section className="uploadImage">
|
|
88
|
-
<input type="button" name="file" id="capture" className="inputfile" accept="image/*"
|
|
89
|
-
capture="environment" onClick={handlers.onCameraClick}/>
|
|
90
|
-
<input type="file" name="file" id="capture_file" className="inputfile" accept={acceptTypes}
|
|
91
|
-
capture="environment"/>
|
|
92
|
-
<input {...getInputProps()} type="file" name="file" id="select_file" className="inputfile"
|
|
93
|
-
accept={acceptTypes}
|
|
94
|
-
onChange={makeFileHandler(handlers.onSelectFile)}
|
|
95
|
-
/>
|
|
96
|
-
<div className="onDesktop">
|
|
97
|
-
Drop an image
|
|
98
|
-
<div className="smallText">or</div>
|
|
99
|
-
</div>
|
|
100
|
-
<div className="onMobile camIcon">
|
|
101
|
-
<img src="./images/ic_cam_large.svg" alt="Camera"/>
|
|
102
|
-
</div>
|
|
103
|
-
<label htmlFor="capture" className="btn primary onMobile"
|
|
104
|
-
style={{marginBottom: '2em', width: '22em'}}>
|
|
105
|
-
<span className="onMobile">Take a picture</span>
|
|
106
|
-
</label>
|
|
107
|
-
<br/>
|
|
108
|
-
<label htmlFor="select_file" className="btn primary" style={{width: '22em'}}>
|
|
109
|
-
<span>Select a file</span>
|
|
110
|
-
</label>
|
|
111
|
-
<label htmlFor="capture" className="mobileUploadHandler onMobile"/>
|
|
112
|
-
</section>
|
|
113
|
-
<ExampleImages images={settings.exampleImages} onExampleImageClicked={handlers.onExampleImageClick}/>
|
|
114
|
-
|
|
115
|
-
</Box>
|
|
116
|
-
</div>
|
|
117
|
-
</div>
|
|
118
|
-
|
|
119
|
-
<div className="headerSeparatorTop"/>
|
|
120
|
-
<div className="headerSeparatorBack"/>
|
|
121
|
-
<div className={classNames('tryDifferent', {hidden: showPart !== 'results'})}
|
|
122
|
-
onClick={handlers.onShowStart}>
|
|
123
|
-
<div className="icIcon">
|
|
124
|
-
</div>
|
|
125
|
-
<div className="textDesc"> Try a different image</div>
|
|
126
|
-
<br style={{clear: 'both'}}/>
|
|
127
|
-
</div>
|
|
128
|
-
</div>
|
|
129
|
-
|
|
130
|
-
<section className={classNames({hideResults: showPart !== 'results'},'results', {resultsActive: showPart === 'results'}, (results.length === 1 ? 'singleProduct' : 'multipleProducts'))}>
|
|
131
|
-
{errorMessage &&
|
|
132
|
-
<div className="errorMsg">
|
|
133
|
-
{errorMessage}
|
|
134
|
-
<div style={{textAlign: 'center', fontSize: '0ß.7em', paddingTop: '0.8em'}}><span>Make sure to include the request ID when reporting a problem: {requestId}</span>
|
|
135
|
-
</div>
|
|
136
|
-
</div>
|
|
137
|
-
}
|
|
138
|
-
<Animate show={loading} start={{opacity: 0.0}} enter={{opacity: [1.0], timing: {duration: 300}}}
|
|
139
|
-
leave={{opacity: [0.0], timing: {duration: 300}}}>
|
|
140
|
-
{s =>
|
|
141
|
-
<div className="loadingOverlay" style={{...s}}>
|
|
142
|
-
<div className="loading"/>
|
|
143
|
-
</div>
|
|
144
|
-
}
|
|
145
|
-
</Animate>
|
|
146
|
-
{settings.preview && previewImage &&
|
|
147
|
-
<div className="preview">
|
|
148
|
-
<Preview key={previewImage.id}
|
|
149
|
-
maxWidth={document.body.clientWidth} maxHeight={maxPreviewHeight}
|
|
150
|
-
dotColor="#4C8F9F"
|
|
151
|
-
onSelectionChange={handlers.onSelectionChange} regions={regions}
|
|
152
|
-
selection={previewSelection} image={previewImage.canvas}/>
|
|
153
|
-
</div>
|
|
154
|
-
}
|
|
155
|
-
<div className="predicted-categories">
|
|
156
|
-
<PredictedCategories cs={categoryPredictions}/>
|
|
157
|
-
</div>
|
|
158
|
-
<div className="predicted-categories">
|
|
159
|
-
<Codes codes={codes}/>
|
|
160
|
-
</div>
|
|
161
|
-
<CategoryFilter cats={filterOptions}/>
|
|
162
|
-
|
|
163
|
-
<div className="wrapper">
|
|
164
|
-
<NodeGroup data={results}
|
|
165
|
-
keyAccessor={r => r.sku}
|
|
166
|
-
start={(r, i) => ({opacity: 0, translateX: -100})}
|
|
167
|
-
enter={(r, i) => ({
|
|
168
|
-
opacity: [1],
|
|
169
|
-
translateX: [0],
|
|
170
|
-
timing: {delay: i * 100, duration: 300}
|
|
171
|
-
})}
|
|
172
|
-
>
|
|
173
|
-
{rs => <>{rs.map(({key, data, state}) => <Result
|
|
174
|
-
key={key}
|
|
175
|
-
noImageUrl={settings.noImageUrl}
|
|
176
|
-
template={settings.resultTemplate}
|
|
177
|
-
onImageClick={handlers.onImageClick}
|
|
178
|
-
onLinkClick={handlers.onLinkClick}
|
|
179
|
-
result={data}
|
|
180
|
-
style={{opacity: state.opacity, transform: `translateX(${state.translateX}%)`}}/>)}</>}
|
|
181
|
-
</NodeGroup>
|
|
182
|
-
|
|
183
|
-
{results.length === 0 && showPart === 'results' && !loading && (
|
|
184
|
-
|
|
185
|
-
<div className="noResults">We did not find anything <span role="img"
|
|
186
|
-
aria-label="sad face">😕</span></div>
|
|
187
|
-
)}
|
|
188
|
-
|
|
189
|
-
<br style={{clear: 'both'}}/>
|
|
190
|
-
|
|
191
|
-
{duration && showPart === 'results' && (<div style={{textAlign: 'center', fontSize: '0.7em', paddingTop: '0.8em'}}>Search
|
|
192
|
-
took {duration.toFixed(2)} seconds</div>)}
|
|
193
|
-
|
|
194
|
-
{requestId && showPart === 'results' && <div style={{textAlign: 'center', fontSize: '0.7em', paddingTop: '0.8em'}}>Request
|
|
195
|
-
identifier {requestId}</div>}
|
|
196
|
-
</div>
|
|
197
|
-
</section>
|
|
198
|
-
|
|
199
|
-
<Snackbar open={toastOpen} autoHideDuration={3000} onClose={() => setToastOpen(false)}>
|
|
200
|
-
<Alert onClose={() => setToastOpen(false)} severity="error">
|
|
201
|
-
{toastErrorMessage}
|
|
202
|
-
</Alert>
|
|
203
|
-
</Snackbar>
|
|
204
|
-
|
|
205
|
-
</div>
|
|
206
|
-
</div>
|
|
207
|
-
<section className="footnote">
|
|
208
|
-
<div className="wrapper">
|
|
209
|
-
© 2017 - 2019 <a href="https://nyris.io">nyris GmbH</a> - All rights reserved - <a
|
|
210
|
-
href="https://nyris.io/imprint/">Imprint</a>
|
|
211
|
-
</div>
|
|
212
|
-
</section>
|
|
213
|
-
<Feedback feedbackState={feedbackState} onPositiveFeedback={handlers.onPositiveFeedback}
|
|
214
|
-
onNegativeFeedback={handlers.onNegativeFeedback} onClose={handlers.onCloseFeedback}/>
|
|
215
|
-
|
|
216
|
-
</React.Fragment>
|
|
217
|
-
);
|
|
218
|
-
}
|
|
219
|
-
|
|
220
|
-
export default Demo2;
|