@nyris/nyris-webapp 0.3.31 → 0.3.32
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 +9 -9
- package/build/index.html +1 -1
- package/build/{precache-manifest.f764cb62c8d24f8090a273fa02dd1a7a.js → precache-manifest.a2c0b5a7cde6667444733c63d9fcb7d5.js} +9 -9
- package/build/service-worker.js +1 -1
- package/build/static/js/2.985a6e2d.chunk.js +3 -0
- package/build/static/js/2.985a6e2d.chunk.js.map +1 -0
- package/build/static/js/main.1e8d5e32.chunk.js +3 -0
- package/build/static/js/main.1e8d5e32.chunk.js.map +1 -0
- package/package.json +5 -4
- package/src/components/DragDropFile.tsx +66 -46
- package/src/components/input/inputSearch.tsx +67 -48
- package/build/static/js/2.5ae21a8b.chunk.js +0 -3
- package/build/static/js/2.5ae21a8b.chunk.js.map +0 -1
- package/build/static/js/main.1edd044c.chunk.js +0 -3
- package/build/static/js/main.1edd044c.chunk.js.map +0 -1
- /package/build/static/js/{2.5ae21a8b.chunk.js.LICENSE.txt → 2.985a6e2d.chunk.js.LICENSE.txt} +0 -0
- /package/build/static/js/{main.1edd044c.chunk.js.LICENSE.txt → main.1e8d5e32.chunk.js.LICENSE.txt} +0 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nyris/nyris-webapp",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.32",
|
|
4
4
|
"homepage": "./",
|
|
5
5
|
"dependencies": {
|
|
6
6
|
"@algolia/autocomplete-js": "^1.7.1",
|
|
@@ -12,8 +12,8 @@
|
|
|
12
12
|
"@material-ui/data-grid": "^4.0.0-alpha.37",
|
|
13
13
|
"@material-ui/icons": "^4.4.1",
|
|
14
14
|
"@material-ui/lab": "^4.0.0-alpha.60",
|
|
15
|
-
"@nyris/nyris-api": "^0.3.
|
|
16
|
-
"@nyris/nyris-react-components": "^0.3.
|
|
15
|
+
"@nyris/nyris-api": "^0.3.32",
|
|
16
|
+
"@nyris/nyris-react-components": "^0.3.32",
|
|
17
17
|
"@reduxjs/toolkit": "^1.6.1",
|
|
18
18
|
"@splidejs/react-splide": "^0.7.12",
|
|
19
19
|
"@types/blueimp-load-image": "^2.23.4",
|
|
@@ -30,6 +30,7 @@
|
|
|
30
30
|
"blueimp-load-image": "^2.24.0",
|
|
31
31
|
"classnames": "^2.2.6",
|
|
32
32
|
"framer-motion": "^4.1.17",
|
|
33
|
+
"heic2any": "0.0.4",
|
|
33
34
|
"history": "^4.10.1",
|
|
34
35
|
"i18next": "^22.4.14",
|
|
35
36
|
"jotai": "^1.4.7",
|
|
@@ -40,7 +41,7 @@
|
|
|
40
41
|
"qs": "^6.10.3",
|
|
41
42
|
"react": "^17.0.0",
|
|
42
43
|
"react-dom": "^16.13.1",
|
|
43
|
-
"react-dropzone": "^
|
|
44
|
+
"react-dropzone": "^14.2.3",
|
|
44
45
|
"react-hook-form": "^7.27.1",
|
|
45
46
|
"react-hot-toast": "^2.4.0",
|
|
46
47
|
"react-i18next": "^12.2.0",
|
|
@@ -19,6 +19,7 @@ import { useState } from 'react';
|
|
|
19
19
|
import IconUpload from 'common/assets/images/Icon_Upload.svg';
|
|
20
20
|
import { RectCoords } from '@nyris/nyris-api';
|
|
21
21
|
import { useTranslation } from 'react-i18next';
|
|
22
|
+
import heic2any from 'heic2any';
|
|
22
23
|
|
|
23
24
|
interface Props {
|
|
24
25
|
acceptTypes: any;
|
|
@@ -37,55 +38,74 @@ function DragDropFile(props: Props) {
|
|
|
37
38
|
} = searchState;
|
|
38
39
|
const [isLoadingLoadFile, setLoadingLoadFile] = useState<any>(false);
|
|
39
40
|
const { t } = useTranslation();
|
|
40
|
-
const
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
let image = await createImage(fs[0]);
|
|
52
|
-
dispatch(setRequestImage(image));
|
|
53
|
-
const preFilter = [
|
|
54
|
-
{
|
|
55
|
-
key: settings.visualSearchFilterKey,
|
|
56
|
-
values: [`${keyFilter}`],
|
|
57
|
-
},
|
|
58
|
-
];
|
|
59
|
-
let region: RectCoords | undefined;
|
|
60
|
-
if (settings.regions) {
|
|
61
|
-
let res = await findRegions(image, settings);
|
|
62
|
-
dispatch(setRegions(res.regions));
|
|
63
|
-
region = res.selectedRegion;
|
|
64
|
-
dispatch(setSelectedRegion(region));
|
|
65
|
-
}
|
|
41
|
+
const handleVisualSearch = async (blob: Blob) => {
|
|
42
|
+
history.push('/result');
|
|
43
|
+
dispatch(updateStatusLoading(true));
|
|
44
|
+
dispatch(loadingActionResults());
|
|
45
|
+
onChangeLoading(true);
|
|
46
|
+
let payload: any;
|
|
47
|
+
let filters: any[] = [];
|
|
48
|
+
setLoadingLoadFile(true);
|
|
49
|
+
dispatch(setImageSearchInput(URL.createObjectURL(blob)));
|
|
50
|
+
// @ts-ignore
|
|
51
|
+
let image = await createImage(blob);
|
|
66
52
|
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
53
|
+
dispatch(setRequestImage(image));
|
|
54
|
+
const preFilter = [
|
|
55
|
+
{
|
|
56
|
+
key: settings.visualSearchFilterKey,
|
|
57
|
+
values: [`${keyFilter}`],
|
|
58
|
+
},
|
|
59
|
+
];
|
|
60
|
+
let region: RectCoords | undefined;
|
|
61
|
+
if (settings.regions) {
|
|
62
|
+
let res = await findRegions(image, settings);
|
|
63
|
+
dispatch(setRegions(res.regions));
|
|
64
|
+
region = res.selectedRegion;
|
|
65
|
+
dispatch(setSelectedRegion(region));
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
return findByImage({
|
|
69
|
+
image,
|
|
70
|
+
settings,
|
|
71
|
+
region,
|
|
72
|
+
filters: keyFilter ? preFilter : undefined,
|
|
73
|
+
}).then((res: any) => {
|
|
74
|
+
res?.results.map((item: any) => {
|
|
75
|
+
filters.push({
|
|
76
|
+
sku: item.sku,
|
|
77
|
+
score: item.score,
|
|
78
78
|
});
|
|
79
|
-
payload = {
|
|
80
|
-
...res,
|
|
81
|
-
filters,
|
|
82
|
-
};
|
|
83
|
-
dispatch(setSearchResults(payload));
|
|
84
|
-
setLoadingLoadFile(false);
|
|
85
|
-
onChangeLoading(false);
|
|
86
|
-
dispatch(updateStatusLoading(false));
|
|
87
|
-
return dispatch(showFeedback());
|
|
88
79
|
});
|
|
80
|
+
payload = {
|
|
81
|
+
...res,
|
|
82
|
+
filters,
|
|
83
|
+
};
|
|
84
|
+
dispatch(setSearchResults(payload));
|
|
85
|
+
setLoadingLoadFile(false);
|
|
86
|
+
onChangeLoading(false);
|
|
87
|
+
dispatch(updateStatusLoading(false));
|
|
88
|
+
return dispatch(showFeedback());
|
|
89
|
+
});
|
|
90
|
+
};
|
|
91
|
+
const { getRootProps, getInputProps, isDragActive } = useDropzone({
|
|
92
|
+
onDrop: async (fs: File[]) => {
|
|
93
|
+
var file = fs[0];
|
|
94
|
+
if (file.type === 'image/heic') {
|
|
95
|
+
heic2any({
|
|
96
|
+
blob: file as Blob,
|
|
97
|
+
toType: 'image/png',
|
|
98
|
+
quality: 1.0,
|
|
99
|
+
})
|
|
100
|
+
.then(function (resultBlob) {
|
|
101
|
+
handleVisualSearch(resultBlob as Blob);
|
|
102
|
+
})
|
|
103
|
+
.catch(function (error) {
|
|
104
|
+
console.error('Error converting HEIC to PNG:', error);
|
|
105
|
+
});
|
|
106
|
+
} else {
|
|
107
|
+
handleVisualSearch(fs[0]);
|
|
108
|
+
}
|
|
89
109
|
},
|
|
90
110
|
});
|
|
91
111
|
|
|
@@ -31,6 +31,7 @@ import PreFilterComponent from 'components/pre-filter';
|
|
|
31
31
|
import { RectCoords } from '@nyris/nyris-api';
|
|
32
32
|
import { truncateString } from 'helpers/truncateString';
|
|
33
33
|
import { useTranslation } from 'react-i18next';
|
|
34
|
+
import heic2any from 'heic2any';
|
|
34
35
|
|
|
35
36
|
const SearchBox = (props: any) => {
|
|
36
37
|
const { refine, onToggleFilterMobile }: any = props;
|
|
@@ -87,58 +88,76 @@ const SearchBox = (props: any) => {
|
|
|
87
88
|
}, 500),
|
|
88
89
|
[],
|
|
89
90
|
);
|
|
91
|
+
const handleVisualSearch = async (blob: Blob) => {
|
|
92
|
+
dispatch(updateStatusLoading(true));
|
|
93
|
+
dispatch(loadingActionResults());
|
|
94
|
+
if (history.location.pathname !== '/result') {
|
|
95
|
+
history.push('/result');
|
|
96
|
+
}
|
|
97
|
+
let payload: any;
|
|
98
|
+
let filters: any[] = [];
|
|
99
|
+
let region: RectCoords | undefined;
|
|
100
|
+
dispatch(setImageSearchInput(URL.createObjectURL(blob)));
|
|
101
|
+
// @ts-ignore
|
|
102
|
+
let image = await createImage(blob);
|
|
103
|
+
dispatch(setRequestImage(image));
|
|
104
|
+
const preFilter = [
|
|
105
|
+
{
|
|
106
|
+
key: settings.visualSearchFilterKey,
|
|
107
|
+
values: [`${keyFilter}`],
|
|
108
|
+
},
|
|
109
|
+
];
|
|
90
110
|
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
dispatch(
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
}
|
|
98
|
-
let payload: any;
|
|
99
|
-
let filters: any[] = [];
|
|
100
|
-
let region: RectCoords | undefined;
|
|
101
|
-
dispatch(setImageSearchInput(URL.createObjectURL(fs[0])));
|
|
102
|
-
let image = await createImage(fs[0]);
|
|
103
|
-
dispatch(setRequestImage(image));
|
|
104
|
-
const preFilter = [
|
|
105
|
-
{
|
|
106
|
-
key: settings.visualSearchFilterKey,
|
|
107
|
-
values: [`${keyFilter}`],
|
|
108
|
-
},
|
|
109
|
-
];
|
|
110
|
-
|
|
111
|
-
if (settings.regions) {
|
|
112
|
-
let res = await findRegions(image, settings);
|
|
113
|
-
dispatch(setRegions(res.regions));
|
|
114
|
-
region = res.selectedRegion;
|
|
115
|
-
dispatch(setSelectedRegion(region));
|
|
116
|
-
}
|
|
111
|
+
if (settings.regions) {
|
|
112
|
+
let res = await findRegions(image, settings);
|
|
113
|
+
dispatch(setRegions(res.regions));
|
|
114
|
+
region = res.selectedRegion;
|
|
115
|
+
dispatch(setSelectedRegion(region));
|
|
116
|
+
}
|
|
117
117
|
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
});
|
|
118
|
+
return findByImage({
|
|
119
|
+
image,
|
|
120
|
+
settings,
|
|
121
|
+
filters: keyFilter ? preFilter : undefined,
|
|
122
|
+
region,
|
|
123
|
+
})
|
|
124
|
+
.then((res: any) => {
|
|
125
|
+
res?.results.map((item: any) => {
|
|
126
|
+
filters.push({
|
|
127
|
+
sku: item.sku,
|
|
128
|
+
score: item.score,
|
|
130
129
|
});
|
|
131
|
-
payload = {
|
|
132
|
-
...res,
|
|
133
|
-
filters,
|
|
134
|
-
};
|
|
135
|
-
dispatch(setSearchResults(payload));
|
|
136
|
-
dispatch(updateStatusLoading(false));
|
|
137
|
-
})
|
|
138
|
-
.catch((e: any) => {
|
|
139
|
-
console.log('error input search', e);
|
|
140
|
-
dispatch(updateStatusLoading(false));
|
|
141
130
|
});
|
|
131
|
+
payload = {
|
|
132
|
+
...res,
|
|
133
|
+
filters,
|
|
134
|
+
};
|
|
135
|
+
dispatch(setSearchResults(payload));
|
|
136
|
+
dispatch(updateStatusLoading(false));
|
|
137
|
+
})
|
|
138
|
+
.catch((e: any) => {
|
|
139
|
+
console.log('error input search', e);
|
|
140
|
+
dispatch(updateStatusLoading(false));
|
|
141
|
+
});
|
|
142
|
+
};
|
|
143
|
+
const { getInputProps } = useDropzone({
|
|
144
|
+
onDrop: async (fs: File[]) => {
|
|
145
|
+
var file = fs[0];
|
|
146
|
+
if (file.type === 'image/heic') {
|
|
147
|
+
heic2any({
|
|
148
|
+
blob: file as Blob,
|
|
149
|
+
toType: 'image/png',
|
|
150
|
+
quality: 1.0,
|
|
151
|
+
})
|
|
152
|
+
.then(function (resultBlob) {
|
|
153
|
+
handleVisualSearch(resultBlob as Blob);
|
|
154
|
+
})
|
|
155
|
+
.catch(function (error) {
|
|
156
|
+
console.error('Error converting HEIC to PNG:', error);
|
|
157
|
+
});
|
|
158
|
+
} else {
|
|
159
|
+
handleVisualSearch(fs[0]);
|
|
160
|
+
}
|
|
142
161
|
},
|
|
143
162
|
});
|
|
144
163
|
|