diff --git a/package.json b/package.json index 6bc655f..29992e8 100644 --- a/package.json +++ b/package.json @@ -30,7 +30,6 @@ "axios-cache-interceptor": "^1.0.1", "axios-rate-limit": "^1.3.0", "babel-plugin-styled-components": "^2.1.4", - "blaze-slider": "^1.9.3", "date-fns": "^2.28.0", "dayjs": "^1.10.6", "ellipsize": "^0.5.1", @@ -42,6 +41,7 @@ "html-to-text": "^8.1.0", "immer": "^10.0.3", "jsdoc": "^3.6.10", + "keen-slider": "^6.8.6", "lodash": "^4.17.21", "pretty-bytes": "^5.6.0", "prop-types": "^15.8.1", @@ -55,7 +55,6 @@ "react-final-form": "^6.5.9", "react-final-form-arrays": "^3.1.4", "react-loader-spinner": "^4.0.0", - "react-masonry-css": "^1.0.16", "react-modal": "^3.15.1", "react-router": "^6.9.0", "react-router-dom": "^6.9.0", diff --git a/src/client/components/Dashboard/Dashboard.tsx b/src/client/components/Dashboard/Dashboard.tsx index 4919d40..cd70686 100644 --- a/src/client/components/Dashboard/Dashboard.tsx +++ b/src/client/components/Dashboard/Dashboard.tsx @@ -112,111 +112,10 @@ export const Dashboard = (): ReactElement => { // ); return (
-
-

Dashboard

-
- {recentComics?.data.docs.map( - ( - { - _id, - rawFileDetails, - sourcedMetadata: { comicvine, comicInfo, locg }, - inferredMetadata, - acquisition: { - source: { name }, - }, - }, - idx, - ) => { - const { issueName, url } = determineCoverFile({ - rawFileDetails, - comicvine, - comicInfo, - locg, - }); - const { issue, coverURL, icon } = determineExternalMetadata( - name, - { - comicvine, - comicInfo, - locg, - }, - ); - const isComicVineMetadataAvailable = - !isUndefined(comicvine) && - !isUndefined(comicvine.volumeInformation); +

Dashboard

+ - return ( - -
-
- {/* Issue number */} - - - - - - {inferredMetadata.issue.number} - - - {/* File extension */} - - - - - - - {rawFileDetails.extension} - - - {/* Uncompressed status */} - {rawFileDetails?.archive?.uncompressed ? ( - - - - - - ) : null} -
-
- -
-
- {/* ComicInfo.xml presence */} - {!isNil(comicInfo) && !isEmpty(comicInfo) && ( -
- -
- )} - {/* ComicVine metadata presence */} - {isComicVineMetadataAvailable && ( - - {"ComicVine - - )} -
- {/* Raw file presence */} - {isNil(rawFileDetails) && ( - - - - )} -
-
- ); - }, - )} -
-
+ {recentComics && } {/* Wanted comics */} {/* Volume groups */} diff --git a/src/client/components/Dashboard/PullList.tsx b/src/client/components/Dashboard/PullList.tsx index 4cc872d..c43d6ac 100644 --- a/src/client/components/Dashboard/PullList.tsx +++ b/src/client/components/Dashboard/PullList.tsx @@ -2,35 +2,64 @@ import { isNil, map } from "lodash"; import React, { createRef, ReactElement, useCallback, useEffect } from "react"; import Card from "../shared/Carda"; import Header from "../shared/Header"; -import { useDispatch, useSelector } from "react-redux"; -import { getWeeklyPullList } from "../../actions/comicinfo.actions"; import { importToDB } from "../../actions/fileops.actions"; import ellipsize from "ellipsize"; -import Slider from "react-slick"; -import "slick-carousel/slick/slick.css"; -import "slick-carousel/slick/slick-theme.css"; import { Link } from "react-router-dom"; +import axios from "axios"; +import rateLimiter from "axios-rate-limit"; +import { setupCache } from "axios-cache-interceptor"; +import { useQuery } from "@tanstack/react-query"; +import "keen-slider/keen-slider.min.css"; +import { useKeenSlider } from "keen-slider/react"; +import { COMICVINE_SERVICE_URI } from "../../constants/endpoints"; type PullListProps = { issues: any; }; -export const PullList = ({ issues }: PullListProps): ReactElement => { - const dispatch = useDispatch(); - useEffect(() => { - dispatch( - getWeeklyPullList({ - startDate: "2023-9-9", - pageSize: "15", - currentPage: "1", - }), - ); - }, []); - const addToLibrary = useCallback( - (sourceName: string, locgMetadata) => - dispatch(importToDB(sourceName, { locg: locgMetadata })), - [], +const http = rateLimiter(axios.create(), { + maxRequests: 1, + perMilliseconds: 1000, + maxRPS: 1, +}); +const cachedAxios = setupCache(axios); +export const PullList = (): ReactElement => { + // blaze slider + const [sliderRef, instanceRef] = useKeenSlider( + { + loop: true, + slides: { + origin: "auto", + number: 15, + perView: 5, + spacing: 15, + }, + + slideChanged() { + console.log("slide changed"); + }, + }, + [ + // add plugins here + ], ); + + const { + data: pullList, + isSuccess, + isLoading, + } = useQuery({ + queryFn: async () => + await cachedAxios(`${COMICVINE_SERVICE_URI}/getWeeklyPullList`, { + method: "get", + params: { startDate: "2023-9-9", pageSize: "15", currentPage: "1" }, + }), + queryKey: ["pullList"], + }); + console.log(pullList?.data.result); + const addToLibrary = (sourceName: string, locgMetadata) => + importToDB(sourceName, { locg: locgMetadata }); + /* const foo = { coverFile: {}, // pointer to which cover file to use @@ -43,47 +72,13 @@ export const PullList = ({ issues }: PullListProps): ReactElement => { }; */ - const pullList = useSelector((state: RootState) => state.comicInfo.pullList); - let sliderRef = createRef(); - const settings = { - dots: false, - infinite: false, - speed: 500, - slidesToShow: 5, - slidesToScroll: 5, - initialSlide: 0, - responsive: [ - { - breakpoint: 1024, - settings: { - slidesToShow: 3, - slidesToScroll: 3, - infinite: false, - }, - }, - { - breakpoint: 600, - settings: { - slidesToShow: 2, - slidesToScroll: 2, - initialSlide: 0, - }, - }, - { - breakpoint: 480, - settings: { - slidesToShow: 1, - slidesToScroll: 1, - }, - }, - ], - }; + // const pullList = useSelector((state: RootState) => state.comicInfo.pullList); const next = () => { - sliderRef.slickNext(); + // sliderRef.slickNext(); }; const previous = () => { - sliderRef.slickPrev(); + // sliderRef.slickPrev(); }; return ( <> @@ -109,53 +104,35 @@ export const PullList = ({ issues }: PullListProps): ReactElement => {
-
-
- -
-
- -
-
- (sliderRef = c)}> - {!isNil(pullList) && - pullList && - map(pullList, ({ issue }, idx) => { + + {isSuccess && !isLoading && ( +
+ {map(pullList?.data.result, (issue, idx) => { return ( - -
-
- {issue.publisher} -
-
+
+ +
+ {issue.publisher}
-
- + +
); })} - +
+ )} ); }; diff --git a/src/client/components/Dashboard/RecentlyImported.tsx b/src/client/components/Dashboard/RecentlyImported.tsx index ab7fc43..5ccbd02 100644 --- a/src/client/components/Dashboard/RecentlyImported.tsx +++ b/src/client/components/Dashboard/RecentlyImported.tsx @@ -4,47 +4,40 @@ import { Link } from "react-router-dom"; import ellipsize from "ellipsize"; import { isEmpty, isNil, isUndefined, map } from "lodash"; import { detectIssueTypes } from "../../shared/utils/tradepaperback.utils"; -import Masonry from "react-masonry-css"; import { determineCoverFile, determineExternalMetadata, } from "../../shared/utils/metadata.utils"; +import { LIBRARY_SERVICE_HOST } from "../../constants/endpoints"; type RecentlyImportedProps = { - comicBookCovers: any; + comics: any; }; -export const RecentlyImported = ({ - comicBookCovers, -}: RecentlyImportedProps): ReactElement => { - const breakpointColumnsObj = { - default: 5, - 1100: 4, - 700: 2, - 600: 2, - }; +export const RecentlyImported = ( + comics: RecentlyImportedProps, +): ReactElement => { + console.log(comics); return ( - <> -
-

- Recently Imported -

-

+

+
+ {}}> + + Recently Imported + + +

Recent Library activity such as imports, tagging, etc.

- - {map( - comicBookCovers, +
+ {comics?.comics.map( ( { _id, rawFileDetails, sourcedMetadata: { comicvine, comicInfo, locg }, + inferredMetadata, acquisition: { source: { name }, }, @@ -62,85 +55,80 @@ export const RecentlyImported = ({ comicInfo, locg, }); - const isComicBookMetadataAvailable = + const isComicVineMetadataAvailable = !isUndefined(comicvine) && !isUndefined(comicvine.volumeInformation); - const titleElement = ( - - {ellipsize(issueName, 20)} - - ); return ( - - -
- {/* Raw file presence */} - {isNil(rawFileDetails) && ( - - + +
+
+ {/* Issue number */} + + + - )} + + {inferredMetadata.issue.number} + + + {/* File extension */} + + + + + + + {rawFileDetails.extension} + + + {/* Uncompressed status */} + {rawFileDetails?.archive?.uncompressed ? ( + + + + + + ) : null} +
+
+ +
+
{/* ComicInfo.xml presence */} {!isNil(comicInfo) && !isEmpty(comicInfo) && ( - - {"ComicInfo.xml - +
+ +
)} {/* ComicVine metadata presence */} - {isComicBookMetadataAvailable && ( - + {isComicVineMetadataAvailable && ( + {"ComicVine )} - {/* Issue type */} - {isComicBookMetadataAvailable && - !isNil( - detectIssueTypes(comicvine.volumeInformation.description), - ) ? ( - - { - detectIssueTypes( - comicvine.volumeInformation.description, - ).displayName - } - - ) : null}
- - {/* metadata card */} - {!isNil(name) && ( - -
-
- - - -
-
- - {ellipsize(issue, 15)} - -
-
-
- )} - + {/* Raw file presence */} + {isNil(rawFileDetails) && ( + + + + )} +
+
); }, )} - - +
+
); -}; \ No newline at end of file +}; diff --git a/src/client/components/shared/Carda.tsx b/src/client/components/shared/Carda.tsx index 54740c8..1e21891 100644 --- a/src/client/components/shared/Carda.tsx +++ b/src/client/components/shared/Carda.tsx @@ -83,7 +83,7 @@ const renderCard = (props: ICardProps): ReactElement => { case "vertical-2": return ( -
+
Home { + const sliderRef = React.useRef(); + const elRef = React.useRef(); + + useEffect(() => { + // if not already initialized + if (!sliderRef.current) { + sliderRef.current = new BlazeSlider(elRef.current, config); + } + }, []); + + return elRef; +}; diff --git a/yarn.lock b/yarn.lock index 9a97902..7f0b71a 100644 --- a/yarn.lock +++ b/yarn.lock @@ -4111,11 +4111,6 @@ bl@^4.0.3, bl@^4.1.0: inherits "^2.0.4" readable-stream "^3.4.0" -blaze-slider@^1.9.3: - version "1.9.3" - resolved "https://registry.yarnpkg.com/blaze-slider/-/blaze-slider-1.9.3.tgz#cc3b5579072be984dfb8ced226c0e27a411f7bcc" - integrity sha512-u8i4AhbjICF6gpyKeMEg65kupT2JoN+E7yOJjOt3ocUtS+r4SKYU79DPNSBV2Zb61fix4ChIxfPyyRUSmLao5g== - bluebird@^3.7.2: version "3.7.2" resolved "https://registry.yarnpkg.com/bluebird/-/bluebird-3.7.2.tgz#9f229c15be272454ffa973ace0dbee79a1b0c36f" @@ -7525,6 +7520,11 @@ jsonfile@^6.0.1: object.assign "^4.1.4" object.values "^1.1.6" +keen-slider@^6.8.6: + version "6.8.6" + resolved "https://registry.yarnpkg.com/keen-slider/-/keen-slider-6.8.6.tgz#17bb7b219860f291a5ea5fde4496b737bf407a83" + integrity sha512-dcEQ7GDBpCjUQA8XZeWh3oBBLLmyn8aoeIQFGL/NTVkoEOsmlnXqA4QykUm/SncolAZYGsEk/PfUhLZ7mwMM2w== + keyv@^4.5.3: version "4.5.4" resolved "https://registry.yarnpkg.com/keyv/-/keyv-4.5.4.tgz#a879a99e29452f942439f2a405e3af8b31d4de93" @@ -9002,11 +9002,6 @@ react-loader-spinner@^4.0.0: dependencies: prop-types "^15.7.2" -react-masonry-css@^1.0.16: - version "1.0.16" - resolved "https://registry.yarnpkg.com/react-masonry-css/-/react-masonry-css-1.0.16.tgz#72b28b4ae3484e250534700860597553a10f1a2c" - integrity sha512-KSW0hR2VQmltt/qAa3eXOctQDyOu7+ZBevtKgpNDSzT7k5LA/0XntNa9z9HKCdz3QlxmJHglTZ18e4sX4V8zZQ== - react-modal@^3.14.3, react-modal@^3.15.1: version "3.16.1" resolved "https://registry.yarnpkg.com/react-modal/-/react-modal-3.16.1.tgz#34018528fc206561b1a5467fc3beeaddafb39b2b"