From 145427d3fd9322e699fd0baadd0a47238d50a226 Mon Sep 17 00:00:00 2001 From: Rishi Ghan Date: Wed, 29 Nov 2023 21:22:48 -0500 Subject: [PATCH 01/31] =?UTF-8?q?=F0=9F=8F=97=EF=B8=8F=20Acquisition=20Pan?= =?UTF-8?q?el=20refactor=20WIP?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ComicDetail/AcquisitionPanel.tsx | 62 +++++++++++++++++-- .../AirDCPPSettings/AirDCPPHubsForm.tsx | 7 +-- 2 files changed, 59 insertions(+), 10 deletions(-) diff --git a/src/client/components/ComicDetail/AcquisitionPanel.tsx b/src/client/components/ComicDetail/AcquisitionPanel.tsx index 2b25188..325437d 100644 --- a/src/client/components/ComicDetail/AcquisitionPanel.tsx +++ b/src/client/components/ComicDetail/AcquisitionPanel.tsx @@ -71,6 +71,9 @@ export const AcquisitionPanel = ( } const [dcppQuery, setDcppQuery] = useState({}); const [airDCPPSearchResults, setAirDCPPSearchResults] = useState([]); + const [airDCPPSearchStatus, setAirDCPPSearchStatus] = useState(false); + const [airDCPPSearchInstance, setAirDCPPSearchInstance] = useState({}); + const [airDCPPSearchInfo, setAirDCPPSearchInfo] = useState({}); // Construct a AirDC++ query based on metadata inferred, upon component mount // Pre-populate the search input with the search string, so that @@ -94,9 +97,7 @@ export const AcquisitionPanel = ( await ADCPPSocket(); } const instance: SearchInstance = await ADCPPSocket.post("search"); - // dispatch({ - // type: AIRDCPP_SEARCH_IN_PROGRESS, - // }); + setAirDCPPSearchStatus(true); // We want to get notified about every new result in order to make the user experience better await ADCPPSocket.addListener( @@ -142,6 +143,9 @@ export const AcquisitionPanel = ( const currentInstance = await ADCPPSocket.get( `search/${instance.id}`, ); + setAirDCPPSearchInstance(currentInstance); + setAirDCPPSearchInfo(searchInfo); + console.log("Asdas", airDCPPSearchInfo); if (currentInstance.result_count === 0) { // ...nothing was received, show an informative message to the user console.log("No more search results."); @@ -154,6 +158,8 @@ export const AcquisitionPanel = ( // searchInfo, // instance, // }); + setAirDCPPSearchInstance(instance); + setAirDCPPSearchStatus(false); }, instance.id, ); @@ -209,7 +215,6 @@ export const AcquisitionPanel = ( }, [], ); - console.log("yaman", airDCPPSearchResults); return ( <>
@@ -245,7 +250,7 @@ export const AcquisitionPanel = (
-- 2.49.1 From dfd99e45b64902ceb55761e57b3799372a810af1 Mon Sep 17 00:00:00 2001 From: Rishi Ghan Date: Wed, 29 Nov 2023 23:24:34 -0500 Subject: [PATCH 03/31] =?UTF-8?q?=F0=9F=94=A7=20Implementing=20download=20?= =?UTF-8?q?method?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ComicDetail/AcquisitionPanel.tsx | 93 ++++++++++++++----- 1 file changed, 70 insertions(+), 23 deletions(-) diff --git a/src/client/components/ComicDetail/AcquisitionPanel.tsx b/src/client/components/ComicDetail/AcquisitionPanel.tsx index 4de7ff8..3c40b3f 100644 --- a/src/client/components/ComicDetail/AcquisitionPanel.tsx +++ b/src/client/components/ComicDetail/AcquisitionPanel.tsx @@ -1,9 +1,5 @@ import React, { useCallback, ReactElement, useEffect, useState } from "react"; -import { - downloadAirDCPPItem, - getBundlesForComic, - sleep, -} from "../../actions/airdcpp.actions"; +import { getBundlesForComic, sleep } from "../../actions/airdcpp.actions"; import { SearchQuery, PriorityEnum, SearchResponse } from "threetwo-ui-typings"; import { RootState, SearchInstance } from "threetwo-ui-typings"; import ellipsize from "ellipsize"; @@ -13,6 +9,7 @@ import { isEmpty, isNil, map } from "lodash"; import { useStore } from "../../store"; import { useShallow } from "zustand/react/shallow"; import { useQuery } from "@tanstack/react-query"; +import axios from "axios"; interface IAcquisitionPanelProps { query: any; @@ -45,25 +42,8 @@ export const AcquisitionPanel = ( }); const issueName = props.query.issue.name || ""; - // const { settings } = props; const sanitizedIssueName = issueName.replace(/[^a-zA-Z0-9 ]/g, " "); - // Selectors for picking state - // const airDCPPSearchResults = useSelector((state: RootState) => { - // return state.airdcpp.searchResults; - // }); - // const isAirDCPPSearchInProgress = useSelector( - // (state: RootState) => state.airdcpp.isAirDCPPSearchInProgress, - // ); - // const searchInfo = useSelector( - // (state: RootState) => state.airdcpp.searchInfo, - // ); - // const searchInstance: SearchInstance = useSelector( - // (state: RootState) => state.airdcpp.searchInstance, - // ); - - // const settings = useSelector((state: RootState) => state.settings.data); - // const airDCPPConfiguration = useContext(AirDCPPSocketContext); interface SearchData { query: Pick & Partial>; hub_urls: string[] | undefined | null; @@ -91,6 +71,11 @@ export const AcquisitionPanel = ( setDcppQuery(dcppSearchQuery); }, []); + /** + * Method to perform a search via an AirDC++ websocket + * @param {SearchData} data - a SearchData query + * @param {any} ADCPPSocket - an intialized AirDC++ socket instance + */ const search = async (data: SearchData, ADCPPSocket: any) => { try { if (!ADCPPSocket.isConnected()) { @@ -165,6 +150,68 @@ export const AcquisitionPanel = ( throw error; } }; + + /** + * Method to download a bundle associated with a search result from AirDC++ + * @param {Number} searchInstanceId - description + * @param {String} resultId - description + * @param {String} comicObjectId - description + * @param {String} name - description + * @param {Number} size - description + * @param {any} type - description + * @param {any} ADCPPSocket - description + * @returns {void} - description + */ + const download = async ( + searchInstanceId: Number, + resultId: String, + comicObjectId: String, + name: String, + size: Number, + type: any, + ADCPPSocket: any, + ): void => { + try { + if (!ADCPPSocket.isConnected()) { + await ADCPPSocket.connect(); + } + let bundleDBImportResult = {}; + const downloadResult = await ADCPPSocket.post( + `search/${searchInstanceId}/results/${resultId}/download`, + ); + + if (!isNil(downloadResult)) { + bundleDBImportResult = await axios({ + method: "POST", + url: `${LIBRARY_SERVICE_BASE_URI}/applyAirDCPPDownloadMetadata`, + headers: { + "Content-Type": "application/json; charset=utf-8", + }, + data: { + bundleId: downloadResult.bundle_info.id, + comicObjectId, + name, + size, + type, + }, + }); + + // dispatch({ + // type: AIRDCPP_RESULT_DOWNLOAD_INITIATED, + // downloadResult, + // bundleDBImportResult, + // }); + // + // dispatch({ + // type: IMS_COMIC_BOOK_DB_OBJECT_FETCHED, + // comicBookDetail: bundleDBImportResult.data, + // IMS_inProgress: false, + // }); + } + } catch (error) { + throw error; + } + }; const getDCPPSearchResults = async (searchQuery) => { const manualQuery = { query: { @@ -396,7 +443,7 @@ export const AcquisitionPanel = ( -

+

*/} +
+ +
{importJobQueue.status !== "drained" && !isUndefined(importJobQueue.status) && ( @@ -249,9 +264,9 @@ export const Import = (props: IProps): ReactElement => { {/* Past imports */} {!isLoading && !isEmpty(data?.data) && ( - <> -

Past Imports

- +
+

Past Imports

+
@@ -291,7 +306,7 @@ export const Import = (props: IProps): ReactElement => { })}
Time Started
- + )} diff --git a/src/client/components/shared/Navbar2.tsx b/src/client/components/shared/Navbar2.tsx index df9b33e..8afff16 100644 --- a/src/client/components/shared/Navbar2.tsx +++ b/src/client/components/shared/Navbar2.tsx @@ -82,9 +82,7 @@ export const Navbar2 = (): ReactElement => { className="flex items-center space-x-1 text-gray-500 transition hover:text-gray-500/75 dark:text-white dark:hover:text-white/75" > - - - + Settings -- 2.49.1 From c74c443534348011352db9e156e9e7d6bc77f063 Mon Sep 17 00:00:00 2001 From: Rishi Ghan Date: Tue, 5 Dec 2023 21:40:40 -0600 Subject: [PATCH 15/31] =?UTF-8?q?=F0=9F=AA=91=20Cleaning=20up=20the=20tabl?= =?UTF-8?q?e=20styles?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/client/components/Import/Import.tsx | 112 ++++++++++++++---------- 1 file changed, 67 insertions(+), 45 deletions(-) diff --git a/src/client/components/Import/Import.tsx b/src/client/components/Import/Import.tsx index 0d98d49..9cbfb25 100644 --- a/src/client/components/Import/Import.tsx +++ b/src/client/components/Import/Import.tsx @@ -159,7 +159,7 @@ export const Import = (props: IProps): ReactElement => {

@@ -195,9 +195,9 @@ export const Import = (props: IProps): ReactElement => { Start Import

*/} -
+
)}
-- 2.49.1 From a068b82db3d4e389829e88fc000a64adb1343c0f Mon Sep 17 00:00:00 2001 From: Rishi Ghan Date: Wed, 6 Dec 2023 10:58:22 -0600 Subject: [PATCH 16/31] =?UTF-8?q?=F0=9F=8F=97=EF=B8=8F=20Cleaned=20up=20pa?= =?UTF-8?q?st=20imports=20table?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/client/components/Import/Import.tsx | 25 ++++++++++++++---------- src/client/components/shared/Navbar2.tsx | 7 +++---- 2 files changed, 18 insertions(+), 14 deletions(-) diff --git a/src/client/components/Import/Import.tsx b/src/client/components/Import/Import.tsx index 9cbfb25..1c52b25 100644 --- a/src/client/components/Import/Import.tsx +++ b/src/client/components/Import/Import.tsx @@ -265,21 +265,27 @@ export const Import = (props: IProps): ReactElement => { {/* Past imports */} {!isLoading && !isEmpty(data?.data) && (
-

Past Imports

+ + + Past Imports + + + +
- - - - @@ -289,29 +295,28 @@ export const Import = (props: IProps): ReactElement => { {data?.data.map((jobResult, id) => { return ( - - - -
+ Time Started + Session Id + Imported + Failed
+ {format( new Date(jobResult.earliestTimestamp), "EEEE, hh:mma, do LLLL Y", )} + {jobResult.sessionId} + -

{jobResult.completedJobs}

+ diff --git a/src/client/components/shared/Navbar2.tsx b/src/client/components/shared/Navbar2.tsx index 8afff16..9c1936c 100644 --- a/src/client/components/shared/Navbar2.tsx +++ b/src/client/components/shared/Navbar2.tsx @@ -9,7 +9,6 @@ export const Navbar2 = (): ReactElement => { const toggleDarkMode = (checked) => { setTheme(colorTheme); setDarkMode(!darkMode); - console.log("here", checked.target.value); }; return ( @@ -26,12 +25,12 @@ export const Navbar2 = (): ReactElement => { >