@nyris/nyris-webapp 0.3.1 → 0.3.4

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 (49) hide show
  1. package/build/asset-manifest.json +11 -11
  2. package/build/index.html +1 -1
  3. package/build/js/test.js +14 -20
  4. package/build/{precache-manifest.3e7aa489925304848e8f04e3015d8567.js → precache-manifest.9800bdc87f5a2c5d6d8a5d1a5287598f.js} +10 -10
  5. package/build/service-worker.js +1 -1
  6. package/build/static/css/{main.b731b101.chunk.css → main.6676fe1f.chunk.css} +2 -2
  7. package/build/static/css/main.6676fe1f.chunk.css.map +1 -0
  8. package/build/static/js/2.29ddd567.chunk.js +3 -0
  9. package/build/static/js/{2.8297cb74.chunk.js.LICENSE.txt → 2.29ddd567.chunk.js.LICENSE.txt} +0 -9
  10. package/build/static/js/2.29ddd567.chunk.js.map +1 -0
  11. package/build/static/js/main.c35ded37.chunk.js +2 -0
  12. package/build/static/js/main.c35ded37.chunk.js.map +1 -0
  13. package/package.json +3 -3
  14. package/public/js/test.js +14 -20
  15. package/src/App.tsx +2 -5
  16. package/src/Store/Nyris.ts +7 -7
  17. package/src/Store/Search.ts +11 -10
  18. package/src/Store/Store.ts +12 -5
  19. package/src/components/CustomHits/index.tsx +57 -0
  20. package/src/components/DragDropFile.tsx +9 -9
  21. package/src/components/ExampleImages.tsx +2 -2
  22. package/src/components/Feedback.tsx +2 -2
  23. package/src/components/FilterComponent.tsx +5 -19
  24. package/src/components/Footer.tsx +1 -1
  25. package/src/components/HeaderMd.tsx +4 -5
  26. package/src/components/LoadingScreen/index.tsx +0 -13
  27. package/src/components/default-select.tsx +1 -2
  28. package/src/index.tsx +2 -1
  29. package/src/modules/LandingPage/{indexApp.tsx → App.tsx} +52 -208
  30. package/src/modules/LandingPage/{indexAppMD.tsx → AppMD.tsx} +52 -147
  31. package/src/modules/LandingPage/common.scss +18 -2
  32. package/src/modules/LandingPage/index.tsx +193 -0
  33. package/src/modules/LandingPage/indexNewVersion.tsx +10 -18
  34. package/src/modules/LandingPage/propsType.ts +43 -0
  35. package/src/page/result/index.tsx +14 -28
  36. package/src/services/findRegionsCustom.ts +0 -197
  37. package/src/services/image.ts +11 -14
  38. package/src/services/session.ts +6 -6
  39. package/src/services/types.ts +1 -15
  40. package/src/types.ts +0 -1
  41. package/build/static/css/main.b731b101.chunk.css.map +0 -1
  42. package/build/static/js/2.8297cb74.chunk.js +0 -3
  43. package/build/static/js/2.8297cb74.chunk.js.map +0 -1
  44. package/build/static/js/main.05909665.chunk.js +0 -2
  45. package/build/static/js/main.05909665.chunk.js.map +0 -1
  46. package/src/App.test.tsx +0 -49
  47. package/src/Store/epics/feedback.ts +0 -59
  48. package/src/Store/epics/types.ts +0 -12
  49. package/src/components/preview/preview.tsx +0 -433
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nyris/nyris-webapp",
3
- "version": "0.3.1",
3
+ "version": "0.3.4",
4
4
  "homepage": "./",
5
5
  "dependencies": {
6
6
  "@babel/runtime": "^7.17.2",
@@ -8,8 +8,8 @@
8
8
  "@material-ui/data-grid": "^4.0.0-alpha.37",
9
9
  "@material-ui/icons": "^4.4.1",
10
10
  "@material-ui/lab": "^4.0.0-alpha.60",
11
- "@nyris/nyris-api": "^0.3.1",
12
- "@nyris/nyris-react-components": "^0.3.1",
11
+ "@nyris/nyris-api": "^0.3.4",
12
+ "@nyris/nyris-react-components": "^0.3.4",
13
13
  "@reduxjs/toolkit": "^1.6.1",
14
14
  "@types/blueimp-load-image": "^2.23.4",
15
15
  "@types/classnames": "^2.2.9",
package/public/js/test.js CHANGED
@@ -12,15 +12,14 @@ var settings = {
12
12
  resultTemplate: "default",
13
13
  responseFormat: "application/offers.complete+json",
14
14
  exampleImages: [
15
- "https://img.nyris.io/demo/everybag/kissen.jpg",
16
- "https://img.nyris.io/demo/everybag/aspirin.jpg",
17
- "https://img.nyris.io/demo/everybag/lego.jpg",
18
- "https://img.nyris.io/demo/everybag/wdr_add_2.jpg",
19
- "https://img.nyris.io/demo/everybag/mb-dle-4.jpg",
15
+ "https://storage.googleapis.com/nyris/share/examples_search/example_1.jpg",
16
+ "https://storage.googleapis.com/nyris/share/examples_search/example_2.jpg",
17
+ "https://storage.googleapis.com/nyris/share/examples_search/example_3.jpg",
18
+ "https://storage.googleapis.com/nyris/share/examples_search/example_4.jpg",
20
19
  ],
21
20
  deactivated: false,
22
21
  cadSearch: false,
23
- theme: {
22
+ themePage: {
24
23
  default: {
25
24
  active: false,
26
25
  },
@@ -40,23 +39,18 @@ var settings = {
40
39
  resultLinkIcon: "eye",
41
40
  },
42
41
  },
43
- searchSuite: {
42
+ newVersion: {
44
43
  active: true,
45
44
  },
46
45
  },
47
-
48
- algolia: {
49
- appIdAlgolia: "HBDJYUK5G4",
50
- indexNameAlgolia: "Normparts",
51
- apiKeyAlgolia: "f6a833ff662086f362b93064b9de6f02",
52
- },
53
- apiNyris: {
54
- imageMatchingUrl: "https://api.nyris.io/find/v1",
55
- imageMatchingUrlBySku: "https://api.nyris.io/recommend/v1",
56
- imageMatchingSubmitManualUrl: "https://api.nyris.io/find/v1/manual",
57
- regionProposalUrl: "https://api.nyris.io/find/v1/regions",
58
- feedbackUrl: "https://api.nyris.io/feedback/v1",
59
- }
46
+ imageMatchingUrl: "https://api.nyris.io/find/v1",
47
+ imageMatchingUrlBySku: "https://api.nyris.io/recommend/v1",
48
+ imageMatchingSubmitManualUrl: "https://api.nyris.io/find/v1/manual",
49
+ regionProposalUrl: "https://api.nyris.io/find/v1/regions",
50
+ feedbackUrl: "https://api.nyris.io/feedback/v1",
51
+ appIdAlgolia: "HBDJYUK5G4",
52
+ indexNameAlgolia: "Normparts",
53
+ apiKeyAlgolia: "f6a833ff662086f362b93064b9de6f02",
60
54
  };
61
55
  settings["customSearchRequest"] = null;
62
56
  settings["responseHook"] = null;
package/src/App.tsx CHANGED
@@ -4,17 +4,14 @@ import React from "react";
4
4
  import "typeface-roboto";
5
5
  import "index.css";
6
6
  import { useAppSelector } from "Store/Store";
7
- import LandingPageApp from "modules/LandingPage/indexApp";
8
- import LandingPageAppMD from "modules/LandingPage/indexAppMD";
7
+ import LandingPageApp from "modules/LandingPage/index";
9
8
  import AppNewVersion from "modules/LandingPage/indexNewVersion";
10
9
  import {AppState} from "./types";
11
10
 
12
11
  function App(): JSX.Element {
13
12
  const { settings } = useAppSelector<AppState>((state: any) => state);
14
13
  const { themePage } = settings;
15
- let SelectedApp =
16
- themePage.default?.active ? LandingPageApp : (
17
- themePage.materialDesign?.active ? LandingPageAppMD : AppNewVersion);
14
+ let SelectedApp = themePage.searchSuite?.active ? AppNewVersion : LandingPageApp;
18
15
 
19
16
  return <SelectedApp />;
20
17
  }
@@ -1,4 +1,4 @@
1
- import { createSlice, PayloadAction } from "@reduxjs/toolkit";
1
+ import { createSlice } from "@reduxjs/toolkit";
2
2
 
3
3
  export type NyrisAppPart = "start" | "camera" | "results";
4
4
  export type NyrisFeedbackState =
@@ -20,7 +20,7 @@ export const nyrisSlice = createSlice({
20
20
  name: "nyris",
21
21
  initialState,
22
22
  reducers: {
23
- showStart: (state, _data: PayloadAction<any>) => {
23
+ showStart: (state) => {
24
24
  return {
25
25
  ...state,
26
26
  showPart: "start",
@@ -32,31 +32,31 @@ export const nyrisSlice = createSlice({
32
32
  showPart: "camera",
33
33
  };
34
34
  },
35
- showResults: (state, _data: PayloadAction<any>) => {
35
+ showResults: (state) => {
36
36
  return {
37
37
  ...state,
38
38
  showPart: "results",
39
39
  };
40
40
  },
41
- showFeedback: (state, _data: PayloadAction<any>) => {
41
+ showFeedback: (state) => {
42
42
  return {
43
43
  ...state,
44
44
  feedbackState: "question",
45
45
  };
46
46
  },
47
- hideFeedback: (state, _data: PayloadAction<any>) => {
47
+ hideFeedback: (state) => {
48
48
  return {
49
49
  ...state,
50
50
  feedbackState: "hidden",
51
51
  };
52
52
  },
53
- feedbackSubmitPositive: (state, _data: PayloadAction<any>) => {
53
+ feedbackSubmitPositive: (state) => {
54
54
  return {
55
55
  ...state,
56
56
  feedbackState: "positive",
57
57
  };
58
58
  },
59
- feedbackNegative: (state, _data: PayloadAction<any>) => {
59
+ feedbackNegative: (state) => {
60
60
  return {
61
61
  ...state,
62
62
  feedbackState: "negative",
@@ -80,11 +80,12 @@ const initialState: SearchState = {
80
80
  loadingSearchAlgolia: false,
81
81
  };
82
82
 
83
- export const searchSlice = createSlice({
84
- name: "search",
85
- initialState,
86
- reducers: {
87
- loadFile: (state, data: PayloadAction<any>) => {
83
+
84
+ export const searchSlice = createSlice({
85
+ name: "search",
86
+ initialState,
87
+ reducers: {
88
+ setSearchResults: (state, data) => {
88
89
  const { payload } = data;
89
90
  const {
90
91
  requestImage,
@@ -144,19 +145,19 @@ export const searchSlice = createSlice({
144
145
  fetchingRegions: false,
145
146
  };
146
147
  },
147
- submitPositiveFeedback: (state, data: PayloadAction<RectCoords>) => {
148
+ submitPositiveFeedback: () => {
148
149
  return;
149
150
  },
150
- submitNegativeFeedback: (state, data: PayloadAction<RectCoords>) => {
151
+ submitNegativeFeedback: () => {
151
152
  return;
152
153
  },
153
- loadingActionResults: (state, _data: PayloadAction<any>) => {
154
+ loadingActionResults: (state) => {
154
155
  return {
155
156
  ...state,
156
157
  fetchingResults: true,
157
158
  };
158
159
  },
159
- loadingActionRegions: (state, _data: PayloadAction<any>) => {
160
+ loadingActionRegions: (state) => {
160
161
  return {
161
162
  ...state,
162
163
  fetchingRegions: true,
@@ -249,7 +250,7 @@ export const searchSlice = createSlice({
249
250
  });
250
251
 
251
252
  export const {
252
- loadFile,
253
+ setSearchResults,
253
254
  selectionChanged,
254
255
  submitPositiveFeedback,
255
256
  submitNegativeFeedback,
@@ -1,21 +1,29 @@
1
1
  import { configureStore } from "@reduxjs/toolkit";
2
2
  import { TypedUseSelectorHook, useDispatch, useSelector } from "react-redux";
3
3
  import { combineReducers } from "redux";
4
- import thunk from "redux-thunk";
5
4
  import Auth from "Store/Auth";
6
- import { AppSettings } from "types";
7
- import { defaultSettings } from "defaults";
5
+ import {AppSettings, MDSettings} from "types";
8
6
  import { getUrlParam } from "utils";
9
7
  import Search from "Store/Search";
10
8
  import Nyris from "Store/Nyris";
9
+ import {defaultMdSettings, defaultSettings} from "../defaults";
11
10
 
12
11
  declare var settings: AppSettings;
13
12
 
13
+
14
+
14
15
  let normalizedSettings: AppSettings = {
15
16
  ...defaultSettings,
16
17
  ...settings,
17
18
  };
18
19
 
20
+ // spread default settings for material design
21
+ let mdSettings : MDSettings = {
22
+ ...defaultMdSettings,
23
+ ...settings.themePage.materialDesign
24
+ }
25
+ normalizedSettings.themePage.materialDesign = mdSettings;
26
+
19
27
  normalizedSettings = {
20
28
  ...normalizedSettings,
21
29
  apiKey: (getUrlParam("apiKey") as string) || normalizedSettings.apiKey,
@@ -28,7 +36,7 @@ normalizedSettings = {
28
36
 
29
37
  const reducers = combineReducers({
30
38
  auth: Auth,
31
- settings: () => normalizedSettings as AppSettings,
39
+ settings: () => normalizedSettings,
32
40
  search: Search,
33
41
  nyris: Nyris,
34
42
  });
@@ -36,7 +44,6 @@ const reducers = combineReducers({
36
44
  export const store = configureStore({
37
45
  reducer: reducers,
38
46
  devTools: process.env.NODE_ENV !== "production",
39
- middleware: [thunk],
40
47
  });
41
48
 
42
49
  export type RootState = ReturnType<typeof store.getState>;
@@ -0,0 +1,57 @@
1
+ import React from "react";
2
+ import PropTypes from "prop-types";
3
+ import { connectHits } from "react-instantsearch-dom";
4
+ import ItemResult from "components/results/ItemResult";
5
+
6
+ function Hits({
7
+ hits,
8
+ setDataResultToAlgolia,
9
+ handlerToggleModal,
10
+ setOpenModalShare,
11
+ setSearchStateInput,
12
+ getUrlToCanvasFile,
13
+ setLoading,
14
+ sendFeedBackAction,
15
+ }: any): JSX.Element {
16
+ const handleSearch = () => {
17
+ setDataResultToAlgolia(hits);
18
+ };
19
+ console.log("hitshits", hits);
20
+
21
+ return (
22
+ <>
23
+ {handleSearch}
24
+ {hits.map((hit: any, index: any) => {
25
+ return (
26
+ <ItemResult
27
+ key={index}
28
+ dataItem={hit}
29
+ handlerToggleModal={() => {
30
+ handlerToggleModal(hit);
31
+ }}
32
+ handlerToggleModalShare={() => setOpenModalShare(true)}
33
+ indexItem={hit.__position}
34
+ isHover={false}
35
+ onSearchImage={(url: any) => {
36
+ setSearchStateInput({});
37
+ getUrlToCanvasFile(url);
38
+ setLoading(true);
39
+ }}
40
+ handlerFeedback={(value: string) => {
41
+ sendFeedBackAction(value);
42
+ }}
43
+ />
44
+ );
45
+ })}
46
+ </>
47
+ );
48
+ }
49
+
50
+ Hits.propTypes = {
51
+ hits: PropTypes.arrayOf(PropTypes.object),
52
+ objectIDs: PropTypes.arrayOf(PropTypes.string),
53
+ setObjectIDs: PropTypes.func,
54
+ };
55
+
56
+ const CustomHits = connectHits(Hits);
57
+ export default CustomHits;
@@ -6,7 +6,7 @@ import { makeFileHandler } from "@nyris/nyris-react-components";
6
6
  import { useAppDispatch, useAppSelector } from "Store/Store";
7
7
  import { serviceImage, serviceImageNonRegion } from "services/image";
8
8
  import {
9
- loadFile,
9
+ setSearchResults,
10
10
  loadingActionResults,
11
11
  searchFileImageNonRegion,
12
12
  } from "Store/Search";
@@ -40,7 +40,7 @@ function DragDropFile(props: Props) {
40
40
  setLoadingLoadFile(true);
41
41
  console.log("fs", fs);
42
42
 
43
- return serviceImage(fs[0], searchState).then((res: any) => {
43
+ return serviceImage(fs[0], searchState.settings).then((res: any) => {
44
44
  console.log("res?.results", res);
45
45
 
46
46
  res?.results.map((item: any) => {
@@ -56,29 +56,29 @@ function DragDropFile(props: Props) {
56
56
  };
57
57
  console.log("payload", payload);
58
58
 
59
- dispatch(loadFile(payload));
59
+ dispatch(setSearchResults(payload));
60
60
  setLoadingLoadFile(false);
61
61
  onChangeLoading(false);
62
62
  history.push("/result");
63
- return dispatch(showFeedback(""));
63
+ return dispatch(showFeedback());
64
64
  });
65
65
  },
66
66
  });
67
67
 
68
68
  const getUrlToCanvasFile = (url: string, position?: number) => {
69
69
  onChangeLoading(true);
70
- dispatch(showResults(""));
71
- dispatch(loadingActionResults(""));
70
+ dispatch(showResults());
71
+ dispatch(loadingActionResults());
72
72
  if (position) {
73
73
  feedbackClickEpic(searchState, position);
74
74
  }
75
75
 
76
76
  if (settings.regions) {
77
- serviceImage(url, searchState).then((res) => {
78
- dispatch(loadFile(res));
77
+ serviceImage(url, searchState.settings).then((res) => {
78
+ dispatch(setSearchResults(res));
79
79
  onChangeLoading(false);
80
80
  history.push("/result");
81
- return dispatch(showFeedback(""));
81
+ return dispatch(showFeedback());
82
82
  });
83
83
  } else {
84
84
  serviceImageNonRegion(url, searchState, rectCoords).then((res) => {
@@ -15,10 +15,10 @@ const ExampleImages: React.FC<ExampleImagesProps> = ({
15
15
  }
16
16
  return (
17
17
  <section className="useExampleImg">
18
- <Typography className="title-box">
18
+ <Typography className="title-box text-center">
19
19
  You can also try one of these pictures:
20
20
  </Typography>
21
- <div className="exampleImages">
21
+ <div className="exampleImages d-flex justify-center">
22
22
  <div className="exImagesWrap">
23
23
  {images.map((i) => {
24
24
  return (
@@ -19,9 +19,9 @@ const Feedback: React.FC<FeedbackProps> = ({ feedbackState, onClose }) => {
19
19
  const onPositiveFeedback = (data: boolean) => {
20
20
  feedbackSuccessEpic(state, data);
21
21
  if (data) {
22
- dispatch(feedbackSubmitPositive(""));
22
+ dispatch(feedbackSubmitPositive());
23
23
  } else {
24
- dispatch(feedbackNegative(""));
24
+ dispatch(feedbackNegative());
25
25
  }
26
26
  };
27
27
 
@@ -2,35 +2,21 @@ import { Box, Button, Grid } from "@material-ui/core";
2
2
  import DefaultSelect from "components/default-select";
3
3
  import React from "react";
4
4
 
5
- interface Props {
6
- dataFieldOne: any[];
7
- dataFieldTow: any[];
8
- dataFieldThree: any[];
9
- dataFieldFour: any[];
10
- dataFieldFive: any[];
11
- dataFieldSix: any[];
12
- }
5
+ interface Props {}
13
6
 
14
7
  function FilterComponent(props: Props) {
15
- const {
16
- dataFieldOne,
17
- dataFieldTow,
18
- dataFieldThree,
19
- dataFieldFour,
20
- dataFieldFive,
21
- dataFieldSix,
22
- } = props;
8
+ const {} = props;
23
9
 
24
10
  return (
25
11
  <Box className="box-main-filter">
26
12
  <Grid container>
27
13
  <Grid item className="item">
28
- <DefaultSelect attribute="brand" />
14
+ <DefaultSelect attribute="brand" />
29
15
  </Grid>
30
16
  <Grid item className="item">
31
- <DefaultSelect attribute="keyword_0" />
17
+ <DefaultSelect attribute="keyword_0" />
32
18
  </Grid>
33
-
19
+
34
20
  <Grid item className="item-seven text-center">
35
21
  <Button
36
22
  className="text-btn-small bg-pink text-red"
@@ -19,7 +19,7 @@ function FooterComponent(): JSX.Element {
19
19
  <Feedback
20
20
  feedbackState={feedbackState}
21
21
  onClose={() => {
22
- return dispatch(hideFeedback(""));
22
+ return dispatch(hideFeedback());
23
23
  }}
24
24
  />
25
25
  </>
@@ -1,17 +1,16 @@
1
1
  import React from "react";
2
2
  import { Container, Toolbar, Typography, AppBar } from "@material-ui/core";
3
- import { defaultMdSettings } from "defaults";
4
3
  import { useAppSelector } from "Store/Store";
4
+ import {MDSettings} from "../types";
5
5
  interface Props {
6
6
  settings: any;
7
7
  }
8
8
 
9
9
  function HeaderMdComponent(): JSX.Element {
10
- const { settings } = useAppSelector((state: any) => state);
10
+ const { settings } = useAppSelector((state) => state);
11
11
  const { themePage } = settings;
12
- const mdSettings: any = themePage.materialDesign.active
13
- ? themePage.materialDesign.materialDesign
14
- : defaultMdSettings;
12
+ const mdSettings = themePage.materialDesign as MDSettings;
13
+
15
14
  return (
16
15
  <AppBar
17
16
  position={"relative"}
@@ -11,19 +11,6 @@ function LoadingScreen({
11
11
  searching,
12
12
  }: any) {
13
13
  const [isLoading] = useState<boolean>(false);
14
- // const hasResults = searchResults && searchResults.nbHits !== 0;
15
-
16
- // useEffect(() => {
17
- // if (searching) {
18
- // return;
19
- // } else {
20
- // setLoading(true);
21
- // setTimeout(() => {
22
- // setLoading(false);
23
- // }, 1000);
24
- // }
25
- // }, [searching, searchResults]);
26
- console.log("searchResults", searchResults);
27
14
 
28
15
  return (
29
16
  <>
@@ -1,6 +1,5 @@
1
- import { Box, MenuItem, Select } from "@material-ui/core";
1
+ import { Box } from "@material-ui/core";
2
2
  import React, { useEffect, useState } from "react";
3
- import KeyboardArrowDownOutlinedIcon from "@material-ui/icons/KeyboardArrowDownOutlined";
4
3
  import { connectMenu } from "react-instantsearch-dom";
5
4
 
6
5
  interface Props {
package/src/index.tsx CHANGED
@@ -20,9 +20,10 @@ document.title = window.location.host;
20
20
 
21
21
  let md: MDSettings = {
22
22
  ...defaultMdSettings,
23
- ...settings.materialDesign,
23
+ ...settings.themePage.materialDesign,
24
24
  };
25
25
 
26
+
26
27
  let theme = createTheme({
27
28
  typography: {
28
29
  fontFamily: md.customFontFamily,