@nyris/nyris-webapp 0.2.6 → 0.3.1

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.
Files changed (199) hide show
  1. package/build/asset-manifest.json +32 -18
  2. package/build/index.html +1 -1
  3. package/build/js/test.js +62 -0
  4. package/build/{precache-manifest.aa7c9d32340f77d86c9a3347b54ba2a5.js → precache-manifest.3e7aa489925304848e8f04e3015d8567.js} +89 -13
  5. package/build/service-worker.js +1 -1
  6. package/build/static/css/2.8285176a.chunk.css +2 -0
  7. package/build/static/css/2.8285176a.chunk.css.map +1 -0
  8. package/build/static/css/main.b731b101.chunk.css +2 -0
  9. package/build/static/css/main.b731b101.chunk.css.map +1 -0
  10. package/build/static/js/2.8297cb74.chunk.js +3 -0
  11. package/build/static/js/2.8297cb74.chunk.js.LICENSE.txt +133 -0
  12. package/build/static/js/2.8297cb74.chunk.js.map +1 -0
  13. package/build/static/js/main.05909665.chunk.js +2 -0
  14. package/build/static/js/main.05909665.chunk.js.map +1 -0
  15. package/build/static/js/{runtime-main.f5553a9b.js → runtime-main.b418ff16.js} +1 -1
  16. package/build/static/js/{runtime-main.f5553a9b.js.map → runtime-main.b418ff16.js.map} +1 -1
  17. package/build/static/media/Fill.37094b44.svg +3 -0
  18. package/build/static/media/Montserrat-Bold.5a052e98.otf +0 -0
  19. package/build/static/media/Montserrat-Light.21789e89.otf +0 -0
  20. package/build/static/media/Montserrat-Medium.a53e0373.otf +0 -0
  21. package/build/static/media/Montserrat-Regular.71cdc681.otf +0 -0
  22. package/build/static/media/Montserrat-SemiBold.f613d915.otf +0 -0
  23. package/build/static/media/Rectangle.4dd8b747.png +0 -0
  24. package/build/static/media/admin.9529c7f6.svg +3 -0
  25. package/build/static/media/bg-support-page.6ac55268.svg +9 -0
  26. package/build/static/media/book_mark.8e294c0b.svg +3 -0
  27. package/build/static/media/icon_dislike.94607ca6.svg +3 -0
  28. package/build/static/media/icon_like.a4fb1b18.svg +3 -0
  29. package/build/static/media/icon_modal_image.3068d0ea.svg +21 -0
  30. package/build/static/media/icon_search_image.c2c728c0.svg +3 -0
  31. package/build/static/media/nyris_logo.22d8f250.svg +3 -0
  32. package/build/static/media/reload_icon.4b579a74.svg +3 -0
  33. package/build/static/media/save_search.bebaeebf.svg +3 -0
  34. package/build/static/media/support.289c3a3c.svg +3 -0
  35. package/build/static/media/translate_icon.f0492297.svg +3 -0
  36. package/package.json +30 -6
  37. package/public/js/test.js +62 -0
  38. package/src/App.css +27 -11
  39. package/src/App.tsx +19 -235
  40. package/src/Router.tsx +97 -0
  41. package/src/Store/Auth.ts +44 -0
  42. package/src/Store/Nyris.ts +77 -0
  43. package/src/Store/Search.ts +269 -0
  44. package/src/Store/Store.ts +46 -0
  45. package/src/Store/common.d.ts +10 -0
  46. package/src/{epics → Store/epics}/feedback.ts +0 -0
  47. package/src/{epics → Store/epics}/types.ts +1 -1
  48. package/src/common/assets/fonts/Montserrat_OTF/Montserrat-Bold.otf +0 -0
  49. package/src/common/assets/fonts/Montserrat_OTF/Montserrat-Light.otf +0 -0
  50. package/src/common/assets/fonts/Montserrat_OTF/Montserrat-Medium.otf +0 -0
  51. package/src/common/assets/fonts/Montserrat_OTF/Montserrat-Regular.otf +0 -0
  52. package/src/common/assets/fonts/Montserrat_OTF/Montserrat-SemiBold.otf +0 -0
  53. package/src/{fonts → common/assets/fonts}/roboto-bold-webfont.woff +0 -0
  54. package/src/{fonts → common/assets/fonts}/roboto-bold-webfont.woff2 +0 -0
  55. package/src/{fonts → common/assets/fonts}/roboto-italic-webfont.woff +0 -0
  56. package/src/{fonts → common/assets/fonts}/roboto-italic-webfont.woff2 +0 -0
  57. package/src/{fonts → common/assets/fonts}/roboto-regular-webfont.woff +0 -0
  58. package/src/{fonts → common/assets/fonts}/roboto-regular-webfont.woff2 +0 -0
  59. package/src/{fonts → common/assets/fonts}/robotocondensed-bold-webfont.woff +0 -0
  60. package/src/{fonts → common/assets/fonts}/robotocondensed-bold-webfont.woff2 +0 -0
  61. package/src/{fonts → common/assets/fonts}/robotocondensed-bolditalic-webfont.woff +0 -0
  62. package/src/{fonts → common/assets/fonts}/robotocondensed-bolditalic-webfont.woff2 +0 -0
  63. package/src/common/assets/icons/Fill.png +0 -0
  64. package/src/common/assets/icons/Fill.svg +3 -0
  65. package/src/common/assets/icons/Icon_wechat.png +0 -0
  66. package/src/common/assets/icons/Icon_whatsapp.png +0 -0
  67. package/src/common/assets/icons/admin.png +0 -0
  68. package/src/common/assets/icons/admin.svg +3 -0
  69. package/src/common/assets/icons/book_mark.png +0 -0
  70. package/src/common/assets/icons/book_mark.svg +3 -0
  71. package/src/common/assets/icons/icon_barcode.png +0 -0
  72. package/src/common/assets/icons/icon_camera.png +0 -0
  73. package/src/common/assets/icons/icon_dislike.svg +3 -0
  74. package/src/common/assets/icons/icon_disslike.png +0 -0
  75. package/src/common/assets/icons/icon_email.png +0 -0
  76. package/src/common/assets/icons/icon_like.png +0 -0
  77. package/src/common/assets/icons/icon_like.svg +3 -0
  78. package/src/common/assets/icons/icon_modal_image.png +0 -0
  79. package/src/common/assets/icons/icon_modal_image.svg +21 -0
  80. package/src/common/assets/icons/icon_picture.png +0 -0
  81. package/src/common/assets/icons/icon_search_image.png +0 -0
  82. package/src/common/assets/icons/icon_search_image.svg +3 -0
  83. package/src/common/assets/icons/nyris_logo.svg +3 -0
  84. package/src/common/assets/icons/reload_icon.png +0 -0
  85. package/src/common/assets/icons/reload_icon.svg +3 -0
  86. package/src/common/assets/icons/save_search.png +0 -0
  87. package/src/common/assets/icons/save_search.svg +3 -0
  88. package/src/common/assets/icons/setting_search_icon.png +0 -0
  89. package/src/common/assets/icons/support.png +0 -0
  90. package/src/common/assets/icons/support.svg +3 -0
  91. package/src/common/assets/icons/translate_icon.png +0 -0
  92. package/src/common/assets/icons/translate_icon.svg +3 -0
  93. package/src/common/assets/icons/view_off.png +0 -0
  94. package/src/common/assets/images/Rectangle.png +0 -0
  95. package/src/common/assets/images/bg-support-page.svg +9 -0
  96. package/src/{images → common/assets/images}/fav/android-icon-192x192.png +0 -0
  97. package/src/{images → common/assets/images}/fav/apple-icon-114x114.png +0 -0
  98. package/src/{images → common/assets/images}/fav/apple-icon-120x120.png +0 -0
  99. package/src/{images → common/assets/images}/fav/apple-icon-144x144.png +0 -0
  100. package/src/{images → common/assets/images}/fav/apple-icon-152x152.png +0 -0
  101. package/src/{images → common/assets/images}/fav/apple-icon-180x180.png +0 -0
  102. package/src/{images → common/assets/images}/fav/apple-icon-57x57.png +0 -0
  103. package/src/{images → common/assets/images}/fav/apple-icon-60x60.png +0 -0
  104. package/src/{images → common/assets/images}/fav/apple-icon-72x72.png +0 -0
  105. package/src/{images → common/assets/images}/fav/apple-icon-76x76.png +0 -0
  106. package/src/{images → common/assets/images}/fav/browserconfig.xml +0 -0
  107. package/src/{images → common/assets/images}/fav/favicon-16x16.png +0 -0
  108. package/src/{images → common/assets/images}/fav/favicon-32x32.png +0 -0
  109. package/src/{images → common/assets/images}/fav/favicon-96x96.png +0 -0
  110. package/src/{images → common/assets/images}/fav/manifest.json +0 -0
  111. package/src/{images → common/assets/images}/ic_cam.png +0 -0
  112. package/src/{images → common/assets/images}/ic_cam.svg +0 -0
  113. package/src/{images → common/assets/images}/ic_cam_large.png +0 -0
  114. package/src/{images → common/assets/images}/ic_cam_large.svg +0 -0
  115. package/src/{images → common/assets/images}/ic_cam_large_noimage.png +0 -0
  116. package/src/{images → common/assets/images}/ic_close_feedback.png +0 -0
  117. package/src/{images → common/assets/images}/ic_close_feedback.svg +0 -0
  118. package/src/{images → common/assets/images}/ic_shopNow.png +0 -0
  119. package/src/{images → common/assets/images}/ic_shopNow.svg +0 -0
  120. package/src/{images → common/assets/images}/ic_shopNowLight.png +0 -0
  121. package/src/{images → common/assets/images}/ic_shopNowLight.svg +0 -0
  122. package/src/common/assets/images/image_test.png +0 -0
  123. package/src/{images → common/assets/images}/nyris_logo.png +0 -0
  124. package/src/{images → common/assets/images}/rewe.svg +0 -0
  125. package/src/{images → common/assets/images}/sectionTransBack.png +0 -0
  126. package/src/{images → common/assets/images}/sectionTransBack.svg +0 -0
  127. package/src/{images → common/assets/images}/sectionTransTop.png +0 -0
  128. package/src/{images → common/assets/images}/sectionTransTop.svg +0 -0
  129. package/src/components/DetailItem.tsx +175 -0
  130. package/src/components/DragDropFile.tsx +188 -0
  131. package/src/components/ExampleImages.tsx +32 -17
  132. package/src/components/Feedback.tsx +87 -48
  133. package/src/components/FilterComponent.tsx +47 -0
  134. package/src/components/Footer.tsx +29 -0
  135. package/src/components/FooterMD.tsx +54 -0
  136. package/src/components/FooterNewVersion.tsx +12 -0
  137. package/src/components/FooterResult.tsx +47 -0
  138. package/src/components/Header.tsx +35 -0
  139. package/src/components/HeaderMd.tsx +39 -0
  140. package/src/components/HeaderNewVersion.tsx +92 -0
  141. package/src/components/Layout.tsx +46 -0
  142. package/src/components/LoadingScreen/index.tsx +42 -0
  143. package/src/components/Navigation.tsx +34 -0
  144. package/src/components/Panigation/Pagination.tsx +140 -0
  145. package/src/components/Panigation/cx.js +3 -0
  146. package/src/components/Panigation/isModifierClick.js +10 -0
  147. package/src/components/Result.tsx +186 -113
  148. package/src/components/Saved/AllItem.tsx +32 -0
  149. package/src/components/Saved/Category.tsx +16 -0
  150. package/src/components/carousel/DefaultCarousel.tsx +48 -0
  151. package/src/components/common.d.ts +9 -0
  152. package/src/components/common.scss +54 -0
  153. package/src/components/default-select.tsx +45 -0
  154. package/src/components/hitItem/hits.tsx +50 -0
  155. package/src/components/hitItem/infinitiHits.tsx +33 -0
  156. package/src/components/input/inputSearch.tsx +77 -0
  157. package/src/components/modal/DefaultModal.tsx +28 -0
  158. package/src/components/preview/preview.tsx +433 -0
  159. package/src/components/results/ItemResult.tsx +155 -0
  160. package/src/components/search/ListSearch.tsx +209 -0
  161. package/src/defaults.ts +4 -3
  162. package/src/index.css +577 -306
  163. package/src/index.tsx +39 -187
  164. package/src/modules/LandingPage/common.scss +1288 -0
  165. package/src/modules/LandingPage/indexApp.tsx +474 -0
  166. package/src/modules/LandingPage/indexAppMD.tsx +494 -0
  167. package/src/modules/LandingPage/indexNewVersion.tsx +118 -0
  168. package/src/page/Auth/login.tsx +7 -0
  169. package/src/page/Exception/404.tsx +11 -0
  170. package/src/page/History/index.tsx +76 -0
  171. package/src/page/Profile/index.tsx +87 -0
  172. package/src/page/Saved/MockData.ts +223 -0
  173. package/src/page/Saved/index.tsx +166 -0
  174. package/src/page/Support/index.tsx +160 -0
  175. package/src/page/result/MockData.ts +36 -0
  176. package/src/page/result/index.tsx +482 -0
  177. package/src/services/Feedback.ts +65 -0
  178. package/src/services/findByImage.ts +24 -0
  179. package/src/services/findRegionsCustom.ts +212 -0
  180. package/src/services/image.ts +110 -0
  181. package/src/services/nyris.ts +123 -0
  182. package/src/services/session.ts +20 -0
  183. package/src/services/types.ts +96 -0
  184. package/src/types.ts +43 -3
  185. package/tsconfig.json +3 -8
  186. package/build/static/css/2.43a1c8b7.chunk.css +0 -2
  187. package/build/static/css/2.43a1c8b7.chunk.css.map +0 -1
  188. package/build/static/css/main.f6ed5f12.chunk.css +0 -2
  189. package/build/static/css/main.f6ed5f12.chunk.css.map +0 -1
  190. package/build/static/js/2.a591d52a.chunk.js +0 -3
  191. package/build/static/js/2.a591d52a.chunk.js.LICENSE.txt +0 -79
  192. package/build/static/js/2.a591d52a.chunk.js.map +0 -1
  193. package/build/static/js/main.5a3dcfb4.chunk.js +0 -2
  194. package/build/static/js/main.5a3dcfb4.chunk.js.map +0 -1
  195. package/src/AppMD.tsx +0 -320
  196. package/src/actions/nyrisAppActions.ts +0 -76
  197. package/src/actions/searchActions.ts +0 -143
  198. package/src/epics/index.ts +0 -149
  199. package/src/epics/search.ts +0 -114
package/src/AppMD.tsx DELETED
@@ -1,320 +0,0 @@
1
- import {AppProps} from "./App";
2
- import {useDropzone} from "react-dropzone";
3
- import {
4
- makeStyles,
5
- AppBar,
6
- Button, Card, CardActions, CardContent,
7
- CardMedia, CircularProgress,
8
- Container,
9
- CssBaseline, Fab,
10
- Grid, Hidden,
11
- Link,
12
- Toolbar,
13
- Typography
14
- } from "@material-ui/core";
15
- import {PhotoCamera, ArrowBack, Image} from "@material-ui/icons";
16
- import Icon from "@material-ui/core/Icon";
17
- import * as React from "react";
18
- import {NodeGroup} from "react-move";
19
- import classNames from 'classnames';
20
- import {Capture, Preview} from "@nyris/nyris-react-components";
21
- import {cadExtensions} from "@nyris/nyris-api";
22
-
23
-
24
- const useStyles = makeStyles(theme => ({
25
- icon: {
26
- marginRight: theme.spacing(2),
27
- },
28
- heroContent: {
29
- backgroundColor: theme.palette.background.paper,
30
- padding: theme.spacing(8, 0, 6),
31
- transition: 'all 300ms',
32
- overflow: 'hidden',
33
- height: 500
34
- },
35
- heroContentClosed: {
36
- height: 0,
37
- padding: 0
38
- },
39
- heroButtons: {
40
- marginTop: theme.spacing(4),
41
- },
42
- cardGrid: {
43
- paddingTop: theme.spacing(8),
44
- paddingBottom: theme.spacing(8),
45
- minHeight: 600,
46
- overflow: 'hidden',
47
- transition: 'all 300ms',
48
- },
49
- cardGridCollapsed: {
50
- height: 0,
51
- opacity: 0,
52
- minHeight: 0,
53
- paddingTop: 0,
54
- paddingBottom: 0,
55
- },
56
- card: {
57
- height: '100%',
58
- display: 'flex',
59
- flexDirection: 'column',
60
- },
61
- cardMedia: {
62
- paddingTop: '56.25%', // 16:9
63
- backgroundSize: 'contain'
64
- },
65
- cardContent: {
66
- flexGrow: 1,
67
- paddingBottom: 0
68
- },
69
- footer: {
70
- backgroundColor: theme.palette.background.paper,
71
- padding: theme.spacing(6),
72
- },
73
- withElipsis: {
74
- textOverflow: 'ellipsis',
75
- overflow: 'hidden',
76
- whiteSpace: 'nowrap'
77
- },
78
- loading: {
79
- margin: theme.spacing(2),
80
- },
81
- fabContainer: {
82
- position: 'fixed',
83
- bottom: theme.spacing(2),
84
-
85
- },
86
- fab: {
87
- marginLeft: theme.spacing(2),
88
- },
89
- }));
90
-
91
- const makeFileHandler = (action: any) => (e: any) => {
92
- let file = (e.dataTransfer && e.dataTransfer.files[0]) || e.target.files[0];
93
- if (e.target && e.target.value) {
94
- e.target.value = "";
95
- }
96
-
97
- if (file) {
98
- action(file);
99
- }
100
- };
101
-
102
- function Copyright() {
103
- return (
104
-
105
- <Typography variant="body2" color="textSecondary" align="center">
106
- {'Powered by '}
107
- <Link color="inherit" href="https://nyris.io/" component='a' target="_blank">
108
- nyris.io
109
- </Link>
110
- </Typography>
111
- );
112
- }
113
-
114
-
115
- const AppMD: React.FC<AppProps> = ({settings, handlers, showPart, previewImage, loading, search: {results, regions, previewSelection, requestId, duration}, mdSettings}) => {
116
- const classes = useStyles();
117
- const {getRootProps, getInputProps, isDragActive} = useDropzone({onDrop: (fs: File[]) => handlers.onFileDropped(fs[0])});
118
-
119
- const minPreviewHeight = 400;
120
- const halfOfTheScreenHeight = Math.floor(window.innerHeight * 0.45);
121
- const maxPreviewHeight = Math.max(minPreviewHeight, halfOfTheScreenHeight);
122
- const acceptTypes =
123
- [ 'image/*' ].concat(
124
- settings.cadSearch ? cadExtensions : []
125
- ).join(',');
126
-
127
- return (
128
- <React.Fragment>
129
- {mdSettings.resultLinkIcon && <link rel="stylesheet" href="https://fonts.googleapis.com/icon?family=Material+Icons" />}
130
- <CssBaseline/>
131
- {showPart === 'camera' &&
132
- <Capture onCaptureComplete={handlers.onCaptureComplete} onCaptureCanceled={handlers.onCaptureCanceled}
133
- useAppText='Use default camera app'/>}
134
- <AppBar position={"relative"} style={{backgroundColor: mdSettings.appBarCustomBackgroundColor}}>
135
-
136
- <Container maxWidth='md' style={{flexDirection: 'row', display: 'flex'}}>
137
- <img src={mdSettings.appBarLogoUrl} style={{height: '2em', minHeight: '64px', display: 'flex'}} alt="Logo"/>
138
- <Toolbar component="span">
139
- <Typography style={{color: mdSettings.appBarCustomTextColor}}>
140
- { mdSettings.appBarTitle }
141
- </Typography>
142
- </Toolbar>
143
- </Container>
144
- </AppBar>
145
-
146
- <main>
147
- <div
148
- className={classNames(classes.heroContent, showPart === 'results' ? classes.heroContentClosed : null)}>
149
- <Container maxWidth='md'>
150
- <div>
151
- <Hidden mdUp>
152
- <div style={{textAlign: 'center'}}>
153
- <PhotoCamera style={{fontSize: '20em', color: '#cccccc'}}/>
154
- </div>
155
- <div style={{textAlign: 'center'}}>
156
- <Button variant={"contained"} color={"primary"} onClick={handlers.onCameraClick}>Take
157
- a
158
- picture</Button>
159
- </div>
160
- <div style={{textAlign: 'center'}}>
161
- <Typography>
162
- or
163
- </Typography>
164
- </div>
165
- <div style={{textAlign: 'center'}}>
166
- <input
167
- accept={acceptTypes}
168
- id="raised-button-file"
169
- type="file"
170
- onChange={makeFileHandler(handlers.onSelectFile)}
171
- style={{width: '.1px', height: '.1px', overflow: 'hidden', opacity: 0}}
172
- />
173
- <label htmlFor="raised-button-file">
174
- <Button variant={"contained"} color={"primary"} component="span">
175
- Select a file
176
- </Button>
177
- </label>
178
- </div>
179
- </Hidden>
180
- <Hidden smDown>
181
- <div style={{borderStyle: 'dashed', borderWidth: 5, borderColor: isDragActive ? '#ccc' : '#eee', borderRadius: 10, padding: 10, paddingBottom: 30}}
182
- {...getRootProps({ onClick: e => { e.stopPropagation() }}) }>
183
- <div style={{textAlign: 'center'}}>
184
- <Image style={{fontSize: '20em', color: '#cccccc'}}/>
185
- </div>
186
- <div style={{textAlign: 'center'}}>
187
- <Typography variant='body2'>
188
- DROP AN IMAGE
189
- </Typography>
190
- </div>
191
- <div style={{textAlign: 'center'}}>
192
- <Typography variant="subtitle2">
193
- or
194
- </Typography>
195
- </div>
196
- <div style={{textAlign: 'center'}}>
197
- <input
198
- accept={acceptTypes}
199
- id="raised-button-file"
200
- type="file"
201
- {...getInputProps()}
202
- onChange={makeFileHandler(handlers.onSelectFile)}
203
- style={{width: '.1px', height: '.1px', overflow: 'hidden', opacity: 0}}
204
- />
205
- <label htmlFor="raised-button-file">
206
- <Button variant={"contained"} color={"primary"} component="span">
207
- Select an image
208
- </Button>
209
- </label>
210
- </div>
211
- </div>
212
- </Hidden>
213
- </div>
214
- </Container>
215
- </div>
216
- <Container className={classNames(classes.cardGrid, showPart !== 'results' && classes.cardGridCollapsed)}
217
- maxWidth="md">
218
-
219
- { previewImage &&
220
- <Card style={{marginBottom: '4em'}} raised={true}>
221
- <Preview key={previewImage.id}
222
- maxWidth={document.body.clientWidth}
223
- maxHeight={maxPreviewHeight}
224
- dotColor={mdSettings.primaryColor}
225
- onSelectionChange={handlers.onSelectionChange} regions={regions}
226
- selection={previewSelection} image={previewImage.canvas}/>
227
- </Card>
228
- }
229
-
230
- {loading && <div style={{textAlign: 'center'}}>
231
- <CircularProgress className={classes.loading}/>
232
- </div>}
233
-
234
- <Grid container spacing={4}>
235
- <NodeGroup data={results}
236
- keyAccessor={r => r.position + r.sku}
237
- start={(r, i) => ({opacity: 0, translateX: -100})}
238
- enter={(r, i) => ({
239
- opacity: [1],
240
- translateX: [0],
241
- timing: {delay: i * 100, duration: 300}
242
- })}>
243
- {rs =>
244
- <>
245
- {rs.map(({key, data: result, state}) =>
246
- <Grid item key={key} xs={12} sm={4} md={3}>
247
- <Card className={classes.card} style={{
248
- opacity: state.opacity,
249
- position: 'relative',
250
- transform: `translateX(${state.translateX}%)`
251
- }}>
252
- <CardMedia
253
- className={classes.cardMedia}
254
- image={(result.img && result.img.url) || settings.noImageUrl}
255
- title={result.title}
256
- />
257
- <CardContent className={classes.cardContent}>
258
- <Typography gutterBottom variant="subtitle2" component="h5"
259
- className={classes.withElipsis}>
260
- {result[mdSettings.resultFirstRowProperty]}
261
- </Typography>
262
- <Typography variant="body2" className={classes.withElipsis}>
263
- {result[mdSettings.resultSecondRowProperty]}
264
- </Typography>
265
- </CardContent>
266
- {result.l &&
267
- <CardActions>
268
- <Button variant="outlined" style={{marginLeft: 'auto'}}
269
- size="small" color="primary"
270
- onClick={() => handlers.onLinkClick(result.position, result.l)}
271
- onAuxClick={() => handlers.onLinkClick(result.position, result.l)} >
272
- { mdSettings.resultLinkIcon && <React.Fragment>
273
- <Icon>{ mdSettings.resultLinkIcon }</Icon>
274
- {' '}
275
- </React.Fragment> }
276
- {mdSettings.resultLinkText}
277
- </Button>
278
- </CardActions>
279
- }
280
- </Card>
281
- </Grid>
282
- )}
283
- </>
284
- }
285
-
286
- </NodeGroup>
287
-
288
- </Grid>
289
-
290
- {results.length === 0 && showPart === 'results' && !loading && (
291
- <Typography variant="h3" align="center">We did not find anything</Typography>
292
- )}
293
-
294
-
295
- </Container>
296
- {showPart !== 'start' &&
297
- <Container maxWidth='lg'>
298
- <div className={classes.fabContainer}>
299
- <Fab aria-label='back' className={classes.fab} color='primary' onClick={handlers.onShowStart}>
300
- <ArrowBack/>
301
- </Fab>
302
- </div>
303
- </Container>
304
- }
305
-
306
- </main>
307
-
308
- <footer className={classes.footer}>
309
-
310
- <Typography variant="subtitle1" align="center" color="textSecondary">
311
- {requestId && showPart === 'results' && <div style={{textAlign: 'center', fontSize: '0.7em', paddingTop: '0.8em'}}>Request
312
- identifier {requestId}</div>}
313
- </Typography>
314
- <Copyright/>
315
- </footer>
316
- </React.Fragment>
317
- );
318
- };
319
-
320
- export default AppMD;
@@ -1,76 +0,0 @@
1
- import {AppAction} from "../types";
2
-
3
-
4
- export type NyrisAppPart = 'start' | 'camera' | 'results';
5
- export type NyrisFeedbackState = 'hidden' | 'question' | 'positive' | 'negative';
6
-
7
-
8
- export interface NyrisAppState {
9
- showPart: NyrisAppPart,
10
- feedbackState: NyrisFeedbackState
11
- }
12
-
13
- export type NyrisAction =
14
- | { type: 'SHOW_START' }
15
- | { type: 'SHOW_CAMERA' }
16
- | { type: 'SHOW_RESULTS' }
17
- | { type: 'SHOW_FEEDBACK' }
18
- | { type: 'HIDE_FEEDBACK' }
19
- | { type: 'RESULT_LINK_CLICKED', position: number, url: string}
20
- | { type: 'RESULT_IMAGE_CLICKED', position: number, url: string}
21
-
22
-
23
- export const showCamera = () :NyrisAction => ({type: 'SHOW_CAMERA'});
24
- export const showStart = () :NyrisAction => ({type: 'SHOW_START'});
25
- export const showResults = () :NyrisAction => ({type: 'SHOW_RESULTS'});
26
- export const showFeedback = () :NyrisAction => ({type: 'SHOW_FEEDBACK'});
27
- export const hideFeedback = () :NyrisAction => ({type: 'HIDE_FEEDBACK'});
28
-
29
- const initialNyrisState : NyrisAppState = {
30
- showPart: 'start',
31
- feedbackState: 'hidden'
32
- };
33
-
34
- export function reducer(state : NyrisAppState = initialNyrisState, action: AppAction) : NyrisAppState {
35
- switch (action.type) {
36
- case 'SHOW_START':
37
- return {
38
- ...state,
39
- showPart: 'start'
40
- };
41
- case 'SHOW_CAMERA':
42
- return {
43
- ...state,
44
- showPart: 'camera'
45
- };
46
- case 'SEARCH_REQUEST_START':
47
- case 'REGION_REQUEST_START':
48
- case 'SHOW_RESULTS':
49
- return {
50
- ...state,
51
- showPart: 'results'
52
- };
53
- case 'SHOW_FEEDBACK':
54
- return {
55
- ...state,
56
- feedbackState: 'question'
57
- };
58
- case 'HIDE_FEEDBACK':
59
- return {
60
- ...state,
61
- feedbackState: 'hidden'
62
- };
63
- case 'FEEDBACK_SUBMIT_POSITIVE':
64
- return {
65
- ...state,
66
- feedbackState: 'positive'
67
- };
68
- case 'FEEDBACK_SUBMIT_NEGATIVE':
69
- return {
70
- ...state,
71
- feedbackState: 'negative'
72
- };
73
- default:
74
- return state;
75
- }
76
- }
@@ -1,143 +0,0 @@
1
- import {CanvasWithId} from "../types";
2
- import {Code, RectCoords, Region, selectFirstCenteredRegion} from '@nyris/nyris-api';
3
-
4
- export type ImageSourceType =
5
- | { url: string }
6
- | { file: File }
7
- | { image: HTMLCanvasElement }
8
-
9
- export type SearchAction =
10
- | { type: 'FEEDBACK_SUBMIT_POSITIVE' }
11
- | { type: 'FEEDBACK_SUBMIT_NEGATIVE' }
12
- | { type: 'IMAGE_LOADED', image: CanvasWithId }
13
- | { type: 'REGION_REQUEST_START', image: HTMLCanvasElement }
14
- | { type: 'REGION_REQUEST_SUCCEED', regions: Region[] }
15
- | { type: 'REGION_REQUEST_FAIL', reason: string, exception: any }
16
- | { type: 'SEARCH_REQUEST_START', image: HTMLCanvasElement, normalizedRect?: RectCoords }
17
- | { type: 'SEARCH_REQUEST_START', file: File }
18
- | { type: 'SEARCH_REQUEST_SUCCEED', results: any[], requestId: string, duration: number, categoryPredictions: CategoryPrediction[], codes: Code[] }
19
- | { type: 'SEARCH_REQUEST_FAIL', reason: string, exception?: any }
20
- | { type: 'REGION_CHANGED', normalizedRect: RectCoords}
21
- | { type: 'LOAD_IMAGE'} & ImageSourceType
22
- | { type: 'LOAD_FILE', file: File}
23
- | { type: 'CAD_LOADED', file: File}
24
-
25
- interface CategoryPrediction {
26
- name: string,
27
- score: number
28
- }
29
-
30
- export interface SearchState {
31
- results: any[]
32
- duration?: number
33
- requestId?: string
34
- sessionId?: string
35
- regions: Region[]
36
- selectedRegion: RectCoords
37
- fetchingRegions: boolean
38
- fetchingResults: boolean
39
- filterOptions: string[]
40
- requestImage?: CanvasWithId
41
- requestCadFile?: File
42
- categoryPredictions: CategoryPrediction[]
43
- codes: Code[],
44
- errorMessage: string
45
- }
46
-
47
- const initialState : SearchState = {
48
- results: [],
49
- regions: [],
50
- selectedRegion: {x1: 0.1, x2: 0.9, y1: 0.1, y2: 0.9},
51
- requestImage: undefined,
52
- fetchingResults: false,
53
- fetchingRegions: false,
54
- filterOptions: [],
55
- categoryPredictions: [],
56
- codes: [],
57
- errorMessage: ''
58
- };
59
-
60
-
61
- export const loadFile = (file: File ): SearchAction => ({ type: 'LOAD_FILE', file });
62
- export const loadUrl = (url: string): SearchAction => ({ type: 'LOAD_IMAGE', url });
63
- export const loadCanvas = (image: HTMLCanvasElement): SearchAction => ({ type: 'LOAD_IMAGE', image });
64
- export const imageLoaded = (image: HTMLCanvasElement, id: string): SearchAction => ({ type: 'IMAGE_LOADED', image: {canvas: image, id: id} });
65
- export const cadFileLoaded = (file: File, id: string): SearchAction => ({ type: 'CAD_LOADED', file});
66
- export const selectionChanged = (normalizedRect: RectCoords) : SearchAction => ({ type: 'REGION_CHANGED', normalizedRect });
67
- export const searchRegions = (image: HTMLCanvasElement): SearchAction => ({ type: 'REGION_REQUEST_START', image });
68
- export const searchOffersForImage = (image: HTMLCanvasElement, normalizedRect?: RectCoords) : SearchAction => ({
69
- type: 'SEARCH_REQUEST_START',
70
- image,
71
- normalizedRect
72
- });
73
- export const searchOffersForCad = (file: File) : SearchAction => ({
74
- type: 'SEARCH_REQUEST_START',
75
- file
76
- });
77
- export const submitPositiveFeedback = () : SearchAction => ({ type: 'FEEDBACK_SUBMIT_POSITIVE'});
78
- export const submitNegativeFeedback = () : SearchAction => ({ type: 'FEEDBACK_SUBMIT_NEGATIVE'});
79
-
80
- export const reducer = (state : SearchState = initialState, action: SearchAction) => {
81
- switch (action.type) {
82
- case "IMAGE_LOADED":
83
- let { image } = action;
84
- console.log('image', image)
85
- return {
86
- ...initialState,
87
- requestImage: image
88
- };
89
- case "CAD_LOADED":
90
- let { file } = action;
91
- return {
92
- ...initialState,
93
- requestCadFile: file
94
- }
95
- case 'REGION_REQUEST_START':
96
- return {
97
- ...state,
98
- fetchingRegions: true
99
- };
100
- case "REGION_REQUEST_SUCCEED":
101
- return {
102
- ...state,
103
- fetchingRegions: false,
104
- regions: action.regions,
105
- selectedRegion: selectFirstCenteredRegion(action.regions, 0.3, state.selectedRegion)
106
- };
107
- case "REGION_REQUEST_FAIL":
108
- return {
109
- ...state,
110
- fetchingRegions: false,
111
- errorMessage: action.exception.response.data.detail
112
- };
113
- case "SEARCH_REQUEST_START":
114
- return {
115
- ...state,
116
- fetchingResults: true
117
- };
118
- case "SEARCH_REQUEST_SUCCEED":
119
- let { results, requestId, duration, categoryPredictions, codes } = action;
120
- return {
121
- ...state,
122
- results,
123
- requestId,
124
- fetchingResults: false,
125
- sessionId: state.sessionId || requestId,
126
- categoryPredictions,
127
- codes,
128
- duration
129
- };
130
- case "SEARCH_REQUEST_FAIL":
131
- return {
132
- ...state,
133
- fetchingResults: false,
134
- errorMessage: action.reason
135
- };
136
- case "REGION_CHANGED":
137
- return {
138
- ...state,
139
- selectedRegion: action.normalizedRect
140
- }
141
- }
142
- return state;
143
- };
@@ -1,149 +0,0 @@
1
- import {combineEpics, ofType} from "redux-observable";
2
- import {debounceTime, delay, ignoreElements, map, switchMap, tap, withLatestFrom} from "rxjs/operators";
3
- import {showFeedback, showResults} from "../actions/nyrisAppActions";
4
- import {EpicConf} from "./types";
5
- import feedbackEpics from "./feedback";
6
- import searchEpics from "./search";
7
- import {searchOffersForImage, searchOffersForCad, searchRegions} from "../actions/searchActions";
8
- import {AppAction} from "../types";
9
- import {selectFirstCenteredRegion} from "@nyris/nyris-api";
10
-
11
-
12
-
13
- const historyEpic: EpicConf = (action$, state$, {history}) => action$.pipe(
14
- ofType('SHOW_RESULTS', 'SHOW_START'),
15
- tap((action) => {
16
- let { type } = action;
17
- if (type === 'SHOW_RESULTS' && history.location.pathname !== '/results') {
18
- history.push('/results');
19
- }
20
- if (type === 'SHOW_START' && history.location.pathname !== '/') {
21
- history.goBack();
22
- }
23
- }),
24
- ignoreElements()
25
- );
26
-
27
- const onSearchSuccessShowResults: EpicConf = (action$) => action$.pipe(
28
- ofType('SEARCH_REQUEST_SUCCEED'),
29
- map(showResults)
30
- );
31
-
32
- const onSearchSuccessRedirectToSite: EpicConf = (action$, state$) => action$.pipe(
33
- ofType('SEARCH_REQUEST_SUCCEED'),
34
- withLatestFrom(state$),
35
- tap(([action, {settings}]) => {
36
- if (action.type !== 'SEARCH_REQUEST_SUCCEED' || !action.results || action.results.length !== 1) {
37
- return;
38
- }
39
-
40
- const firstLink = action.results[0].l;
41
- const instantRedirectPatterns = settings.instantRedirectPatterns;
42
- if (!instantRedirectPatterns.find(r => new RegExp(r).test(firstLink))) {
43
- return;
44
- }
45
- window.location.href = firstLink;
46
- }),
47
- ignoreElements()
48
- );
49
-
50
- const onSearchSuccessShowFeedbackDelayed: EpicConf = (action$) => action$.pipe(
51
- ofType('SEARCH_REQUEST_SUCCEED'),
52
- delay(3000),
53
- map(showFeedback)
54
- );
55
-
56
-
57
- const startSearchOnImageLoaded: EpicConf = (action$, state$) => action$.pipe(
58
- ofType('IMAGE_LOADED'),
59
- withLatestFrom(state$),
60
- switchMap(async ([action, {settings}]) : Promise<AppAction> => {
61
- if (action.type !== 'IMAGE_LOADED') {
62
- throw new Error(`Wrong action type ${action.type}`);
63
- }
64
-
65
- let { image } = action;
66
-
67
- if (settings.regions) {
68
- return searchRegions(image.canvas);
69
- }
70
- return searchOffersForImage(image.canvas);
71
- })
72
- );
73
-
74
- const startSearchOnCadLoaded: EpicConf = (action$, state$) => action$.pipe(
75
- ofType('CAD_LOADED'),
76
- withLatestFrom(state$),
77
- switchMap(async ([action, {settings}]) : Promise<AppAction> => {
78
- if (action.type !== 'CAD_LOADED') {
79
- throw new Error(`Wrong action type ${action.type}`);
80
- }
81
- let { file } = action;
82
- return searchOffersForCad(file);
83
- })
84
- );
85
-
86
- const startSearchOnRegionsSuccessful: EpicConf = (action$, state$) => action$.pipe(
87
- ofType('REGION_REQUEST_SUCCEED'),
88
- withLatestFrom(state$),
89
- switchMap(async ([action, { search: { requestImage}}]) : Promise<AppAction> => {
90
- if (action.type !== 'REGION_REQUEST_SUCCEED') {
91
- throw new Error(`Wrong action type ${action.type}`);
92
- }
93
- if (!requestImage) {
94
- throw new Error(`No requestImage`);
95
- }
96
- let { regions } = action;
97
-
98
- let selection = selectFirstCenteredRegion(regions, 0.3, {x1: 0, x2: 1, y1: 0, y2: 1});
99
- return searchOffersForImage(requestImage.canvas, selection);
100
- })
101
- );
102
-
103
- const startSearchOnRegionsFailed: EpicConf = (action$, state$) => action$.pipe(
104
- ofType('REGION_REQUEST_FAIL'),
105
- withLatestFrom(state$),
106
- switchMap(async ([action, { search: { requestImage}}]) : Promise<AppAction> => {
107
- if (action.type !== 'REGION_REQUEST_FAIL') {
108
- throw new Error(`Wrong action type ${action.type}`);
109
- }
110
- if (!requestImage) {
111
- throw new Error(`No requestImage`);
112
- }
113
-
114
- return searchOffersForImage(requestImage.canvas);
115
- })
116
- );
117
-
118
- const startSearchOnRegionChange: EpicConf = (action$, state$) => action$.pipe(
119
- ofType('REGION_CHANGED'),
120
- debounceTime(1200),
121
- withLatestFrom(state$),
122
- switchMap(async ([action, { search: { requestImage}}]) : Promise<AppAction> => {
123
- if (action.type !== 'REGION_CHANGED') {
124
- throw new Error(`Wrong action type ${action.type}`);
125
- }
126
- if (!requestImage) {
127
- throw new Error(`No requestImage`);
128
- }
129
- let { normalizedRect } = action;
130
- return searchOffersForImage(requestImage.canvas, normalizedRect);
131
- })
132
- );
133
-
134
-
135
- const rootEpic = combineEpics(
136
- searchEpics,
137
- feedbackEpics,
138
- historyEpic,
139
- startSearchOnImageLoaded,
140
- startSearchOnCadLoaded,
141
- startSearchOnRegionsSuccessful,
142
- startSearchOnRegionsFailed,
143
- startSearchOnRegionChange,
144
- onSearchSuccessShowResults,
145
- onSearchSuccessShowFeedbackDelayed,
146
- onSearchSuccessRedirectToSite
147
- );
148
-
149
- export default rootEpic;