From 2c0664506eeb64fb87d938ecd41f0781de05fcb8 Mon Sep 17 00:00:00 2001 From: Rishi Ghan Date: Tue, 4 Jan 2022 07:54:18 -0800 Subject: [PATCH] =?UTF-8?q?=F0=9F=A6=B8=F0=9F=8F=BB=20Integrating=20with?= =?UTF-8?q?=20Metron=20service?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- package.json | 1 + src/client/actions/fileops.actions.tsx | 8 +--- src/client/actions/metron.actions.tsx | 24 ++++++++++ .../ComicDetail/EditMetadataPanel.tsx | 44 ++++++++++++++++++- src/client/constants/action-types.ts | 5 +++ src/client/constants/endpoints.ts | 7 +++ yarn.lock | 32 ++++++++++++++ 7 files changed, 113 insertions(+), 8 deletions(-) create mode 100644 src/client/actions/metron.actions.tsx diff --git a/package.json b/package.json index 9b3735e..041d35b 100644 --- a/package.json +++ b/package.json @@ -61,6 +61,7 @@ "react-notification-system-redux": "^2.0.1", "react-responsive-carousel": "^3.2.21", "react-select": "^5.2.1", + "react-select-async-paginate": "^0.6.1", "react-sliding-pane": "^7.0.0", "react-stickynode": "^4.0.0", "react-table": "^7.7.0", diff --git a/src/client/actions/fileops.actions.tsx b/src/client/actions/fileops.actions.tsx index 536aa5b..7b4c720 100644 --- a/src/client/actions/fileops.actions.tsx +++ b/src/client/actions/fileops.actions.tsx @@ -1,12 +1,10 @@ import axios from "axios"; -import { IFolderData, IExtractedComicBookCoverFile } from "threetwo-ui-typings"; +import { IFolderData } from "threetwo-ui-typings"; import { - API_BASE_URI, COMICBOOKINFO_SERVICE_URI, IMPORT_SERVICE_BASE_URI, } from "../constants/endpoints"; import { - IMS_COMICBOOK_METADATA_FETCHED, IMS_COMIC_BOOK_GROUPS_FETCHED, IMS_COMIC_BOOK_GROUPS_CALL_IN_PROGRESS, IMS_COMIC_BOOK_GROUPS_CALL_FAILED, @@ -19,8 +17,6 @@ import { IMS_CV_METADATA_IMPORT_FAILED, LS_IMPORT, } from "../constants/action-types"; -import { refineQuery } from "../shared/utils/filenameparser.utils"; -import sortBy from "array-sort-by"; import { success } from "react-notification-system-redux"; import { isNil } from "lodash"; @@ -208,8 +204,6 @@ export const fetchComicVineMatches = }, }); }); - - /* return { issueSearchQuery, series: seriesSearchQuery.searchParams }; */ } catch (error) { console.log(error); } diff --git a/src/client/actions/metron.actions.tsx b/src/client/actions/metron.actions.tsx new file mode 100644 index 0000000..8f8ed20 --- /dev/null +++ b/src/client/actions/metron.actions.tsx @@ -0,0 +1,24 @@ +import axios from "axios"; +import { METRON_SERVICE_URI } from "../constants/endpoints"; +import { + METRON_DATA_FETCH_SUCCESS, + METRON_DATA_FETCH_IN_PROGRESS, +} from "../constants/action-types"; + +export const fetchMetronResource = async (options) => { + console.log(options); + + const metronResourceResults = await axios.post( + `${METRON_SERVICE_URI}/fetchResource`, + options, + ); + console.log(metronResourceResults); + const foo = metronResourceResults.data.results.map((result) => { + return { + label: result.name, + value: result.id, + }; + }); + console.log({ options: foo, hasMore: false }); + return { options: foo, hasMore: false }; +}; diff --git a/src/client/components/ComicDetail/EditMetadataPanel.tsx b/src/client/components/ComicDetail/EditMetadataPanel.tsx index 09de2e6..015ed94 100644 --- a/src/client/components/ComicDetail/EditMetadataPanel.tsx +++ b/src/client/components/ComicDetail/EditMetadataPanel.tsx @@ -1,6 +1,11 @@ -import React, { ReactElement } from "react"; +import React, { ReactElement, useCallback, useEffect, useState } from "react"; +import { useSelector, useDispatch } from "react-redux"; import { Form, Field } from "react-final-form"; import DatePicker from "react-datepicker"; +import Creatable from "react-select/creatable"; +import { fetchMetronResource } from "../../actions/metron.actions"; +import { withAsyncPaginate } from "react-select-async-paginate"; +const CreatableAsyncPaginate = withAsyncPaginate(Creatable); import "react-datepicker/dist/react-datepicker.css"; export const EditMetadataPanel = (props): ReactElement => { @@ -9,6 +14,20 @@ export const EditMetadataPanel = (props): ReactElement => { const DayPickerAdapter = ({ input, ...rest }) => { return ; }; + const dispatch = useDispatch(); + const [value, onChange] = useState(null); + + const mudasir = useCallback((query) => { + return fetchMetronResource({ + method: "GET", + resource: "publisher", + query: { + name: query, + page: 1, + }, + }); + }, []); + return ( <>
{ + + {/* Publisher */} +
+
+ +
+
+
+

+ mudasir(e)} + // onCreateOption={onCreateOption} + onChange={onChange} + // cacheUniqs={[cacheUniq]} + /> +

+
+
+
)} /> diff --git a/src/client/constants/action-types.ts b/src/client/constants/action-types.ts index a848613..41b92f7 100644 --- a/src/client/constants/action-types.ts +++ b/src/client/constants/action-types.ts @@ -69,3 +69,8 @@ export const SETTINGS_OBJECT_FETCHED = "SETTINGS_OBJECT_FETCHED"; export const SETTINGS_CALL_FAILED = "SETTINGS_CALL_FAILED"; export const SETTINGS_OBJECT_DELETED = "SETTINGS_OBJECT_DELETED"; export const SETTINGS_DB_FLUSH_SUCCESS = "SETTINGS_DB_FLUSH_SUCCESS"; + +// Metron Metadata +export const METRON_DATA_FETCH_SUCCESS = "METRON_DATA_FETCH_SUCCESS"; +export const METRON_DATA_FETCH_IN_PROGRESS = "METRON_DATA_FETCH_IN_PROGRESS"; +export const METRON_DATA_FETCH_ERROR = "METRON_DATA_FETCH_ERROR"; diff --git a/src/client/constants/endpoints.ts b/src/client/constants/endpoints.ts index 1719fbb..b59870e 100644 --- a/src/client/constants/endpoints.ts +++ b/src/client/constants/endpoints.ts @@ -23,6 +23,13 @@ export const COMICBOOKINFO_SERVICE_URI = hostURIBuilder({ apiPath: "/api/comicvine", }); +export const METRON_SERVICE_URI = hostURIBuilder({ + protocol: "http", + host: process.env.UNDERLYING_HOSTNAME || "localhost", + port: "3080", + apiPath: "/api/metron", +}); + export const API_BASE_URI = hostURIBuilder({ protocol: "http", host: process.env.UNDERLYING_HOSTNAME || "localhost", diff --git a/yarn.lock b/yarn.lock index 0c83d46..9dc74d4 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1045,6 +1045,13 @@ dependencies: regenerator-runtime "^0.13.4" +"@babel/runtime@^7.16.5": + version "7.16.7" + resolved "https://registry.yarnpkg.com/@babel/runtime/-/runtime-7.16.7.tgz#03ff99f64106588c9c403c6ecb8c3bafbbdff1fa" + integrity sha512-9E9FJowqAsytyOY6LG+1KuueckRL+aQW+mKvXRXnuFGyRAyepJPmEo9vgMfXUA6O9u3IeEdv9MAkppFcaQwogQ== + dependencies: + regenerator-runtime "^0.13.4" + "@babel/template@^7.15.4", "@babel/template@^7.3.3": version "7.15.4" resolved "https://registry.yarnpkg.com/@babel/template/-/template-7.15.4.tgz#51898d35dcf3faa670c4ee6afcfd517ee139f194" @@ -1680,6 +1687,11 @@ domhandler "^4.2.0" selderee "^0.6.0" +"@seznam/compose-react-refs@^1.0.6": + version "1.0.6" + resolved "https://registry.yarnpkg.com/@seznam/compose-react-refs/-/compose-react-refs-1.0.6.tgz#6ec4e70bdd6e32f8e70b4100f27267cf306bd8df" + integrity sha512-izzOXQfeQLonzrIQb8u6LQ8dk+ymz3WXTIXjvOlTXHq6sbzROg3NWU+9TTAOpEoK9Bth24/6F/XrfHJ5yR5n6Q== + "@sindresorhus/is@^0.7.0": version "0.7.0" resolved "https://registry.yarnpkg.com/@sindresorhus/is/-/is-0.7.0.tgz#9a06f4f137ee84d7df0460c1fdb1135ffa6c50fd" @@ -11147,6 +11159,11 @@ react-hot-loader@^4.13.0: shallowequal "^1.1.0" source-map "^0.7.3" +react-is-mounted-hook@^1.1.2: + version "1.1.2" + resolved "https://registry.yarnpkg.com/react-is-mounted-hook/-/react-is-mounted-hook-1.1.2.tgz#0e57d237c0ed60f6a8dc0520634608a80ae864ff" + integrity sha512-yjq3Tj34CiFcdVOS/h6JerWLOLdJqEGKMNpTHc4kWebzz2YtIpgqMRrqxdmQhewM1KJREojdAV2tsNvBsUWyhA== + react-is@^16.13.1, react-is@^16.6.0, react-is@^16.7.0, react-is@^16.8.1: version "16.13.1" resolved "https://registry.yarnpkg.com/react-is/-/react-is-16.13.1.tgz#789729a4dc36de2999dc156dd6c1d9c18cea56a4" @@ -11287,6 +11304,16 @@ react-router@5.2.1, react-router@^5.2.0: tiny-invariant "^1.0.2" tiny-warning "^1.0.0" +react-select-async-paginate@^0.6.1: + version "0.6.1" + resolved "https://registry.yarnpkg.com/react-select-async-paginate/-/react-select-async-paginate-0.6.1.tgz#979810bd09829c14175441b6219280fb53959ab8" + integrity sha512-oFdX8aciCoBEXuP0ouSSan4H/6lYw9w5eCiA3vw9eNSWdFmIU1HzyYrEQbVJDz027kp643e8pKKmO6pWbr21yA== + dependencies: + "@babel/runtime" "^7.16.5" + "@seznam/compose-react-refs" "^1.0.6" + react-is-mounted-hook "^1.1.2" + sleep-promise "^9.1.0" + react-select@^5.2.1: version "5.2.1" resolved "https://registry.yarnpkg.com/react-select/-/react-select-5.2.1.tgz#416c25c6b79b94687702374e019c4f2ed9d159d6" @@ -12291,6 +12318,11 @@ slash@^3.0.0: resolved "https://registry.yarnpkg.com/slash/-/slash-3.0.0.tgz#6539be870c165adbd5240220dbe361f1bc4d4634" integrity sha512-g9Q1haeby36OSStwb4ntCGGGaKsaVSjQ68fBxoQcutl5fS1vuY18H3wSt3jFyFtrkx+Kz0V1G85A4MyAdDMi2Q== +sleep-promise@^9.1.0: + version "9.1.0" + resolved "https://registry.yarnpkg.com/sleep-promise/-/sleep-promise-9.1.0.tgz#101ebe65700bcd184709da95d960967b02b79d03" + integrity sha512-UHYzVpz9Xn8b+jikYSD6bqvf754xL2uBUzDFwiU6NcdZeifPr6UfgU43xpkPu67VMS88+TI2PSI7Eohgqf2fKA== + slice-ansi@^4.0.0: version "4.0.0" resolved "https://registry.yarnpkg.com/slice-ansi/-/slice-ansi-4.0.0.tgz#500e8dd0fd55b05815086255b3195adf2a45fe6b"