diff --git a/src/client/actions/airdcpp.actions.tsx b/src/client/actions/airdcpp.actions.tsx index afca6f4..1a57de2 100644 --- a/src/client/actions/airdcpp.actions.tsx +++ b/src/client/actions/airdcpp.actions.tsx @@ -130,7 +130,7 @@ export const downloadAirDCPPItem = true, ); } - console.log(comicObject) + console.log(comicObject); let bundleDBImportResult = {}; const downloadResult = await ADCPPSocket.post( `search/${instanceId}/results/${resultId}/download`, @@ -162,7 +162,6 @@ export const downloadAirDCPPItem = (item) => item.id, ); } - console.log(comicObjectId) if (!isNil(downloadResult)) { bundleDBImportResult = await axios({ method: "POST", @@ -255,3 +254,21 @@ export const getBundlesForComic = throw error; } }; + +export const getTransfers = + (ADCPPSocket: any, credentials: any) => async (dispatch) => { + try { + if (!ADCPPSocket.isConnected()) { + await ADCPPSocket.connect( + `${credentials.username}`, + `${credentials.password}`, + true, + ); + } + console.log(ADCPPSocket); + const foo = await ADCPPSocket.get('queue/bundles/1/50', {}); + console.log(foo); + } catch (err) { + throw err; + } + }; diff --git a/src/client/components/App.tsx b/src/client/components/App.tsx index 4fa62d1..e90dd19 100644 --- a/src/client/components/App.tsx +++ b/src/client/components/App.tsx @@ -12,6 +12,7 @@ import VolumeDetail from "./VolumeDetail/VolumeDetail"; import PullList from "./PullList/PullList"; import WantedComics from "./WantedComics/WantedComics"; import Volumes from "./Volumes/Volumes"; +import Downloads from "./Downloads/Downloads"; import { Routes, Route } from "react-router-dom"; import Navbar from "./Navbar"; @@ -82,6 +83,7 @@ export const App = (): ReactElement => { } /> } /> } /> + } /> } /> { rawFileDetails, inferredMetadata, sourcedMetadata: { comicvine, locg, comicInfo }, - }, userSettings, + }, + userSettings, } = data; // check for the availability of CV metadata diff --git a/src/client/components/Dashboard/LibraryStatistics.tsx b/src/client/components/Dashboard/LibraryStatistics.tsx index bcb181f..7233f9a 100644 --- a/src/client/components/Dashboard/LibraryStatistics.tsx +++ b/src/client/components/Dashboard/LibraryStatistics.tsx @@ -7,8 +7,8 @@ export const LibraryStatistics = ( ): ReactElement => { // const { stats } = props; return ( - <> -

+
+

Statistics

A brief snapshot of your library.

@@ -110,7 +110,7 @@ export const LibraryStatistics = (
- + ); }; diff --git a/src/client/components/Dashboard/WantedComicsList.tsx b/src/client/components/Dashboard/WantedComicsList.tsx index 6c6095d..aeeca20 100644 --- a/src/client/components/Dashboard/WantedComicsList.tsx +++ b/src/client/components/Dashboard/WantedComicsList.tsx @@ -27,10 +27,10 @@ export const WantedComicsList = ({ }; return ( <> -
+
- Wanted Comics + Wanted Comics diff --git a/src/client/components/Downloads/Downloads.tsx b/src/client/components/Downloads/Downloads.tsx new file mode 100644 index 0000000..52fa2ab --- /dev/null +++ b/src/client/components/Downloads/Downloads.tsx @@ -0,0 +1,51 @@ +import React, { ReactElement, useCallback, useContext, useEffect } from "react"; +import { getSettings } from "../../actions/settings.actions"; +import { getTransfers } from "../../actions/airdcpp.actions"; +import { useDispatch, useSelector } from "react-redux"; +import { AirDCPPSocketContext } from "../../context/AirDCPPSocket"; +import AirDCPPSocket from "../../services/DcppSearchService"; +import { isEmpty, isUndefined } from "lodash"; + +interface IDownloadsProps { + data: any; +} + +export const Downloads = (props: IDownloadsProps): ReactElement => { + const { ADCPPSocket, setADCPPSocket } = useContext(AirDCPPSocketContext); + const dispatch = useDispatch(); + const airDCPPClientSettings = useSelector( + (state: RootState) => state.settings.data, + ); + useEffect(() => { + dispatch(getSettings()); + }, []); + + useEffect(() => { + if (!isEmpty(airDCPPClientSettings)) { + setADCPPSocket( + new AirDCPPSocket({ + hostname: `${airDCPPClientSettings.directConnect.client.host.hostname}`, + protocol: `${airDCPPClientSettings.directConnect.client.host.protocol}`, + }), + ); + } + }, [airDCPPClientSettings]); + + console.log(airDCPPClientSettings); + // Make the call to get all transfers from AirDC++ + useEffect(() => { + if (!isUndefined(ADCPPSocket) && !isEmpty(airDCPPClientSettings)) { + dispatch( + getTransfers(ADCPPSocket, { + username: `${airDCPPClientSettings.directConnect.client.host.username}`, + password: `${airDCPPClientSettings.directConnect.client.host.password}`, + }), + ); + } + }, [ADCPPSocket]); + // const getAllDownloads = useCallback(() => {}); + + return <>; +}; + +export default Downloads; diff --git a/src/client/components/Navbar.tsx b/src/client/components/Navbar.tsx index c33473d..0b00826 100644 --- a/src/client/components/Navbar.tsx +++ b/src/client/components/Navbar.tsx @@ -1,11 +1,8 @@ -import { debounce } from "lodash"; -import React, { ReactElement, useCallback } from "react"; +import React from "react"; import { SearchBar } from "./GlobalSearchBar/SearchBar"; -import { useSelector } from "react-redux"; import { Link } from "react-router-dom"; const Navbar: React.FunctionComponent = (props) => { - return (