📝 Tabulated downloads per comic

This commit is contained in:
2022-07-28 08:59:30 -07:00
parent 602adf8775
commit f146dfdd0b
5 changed files with 60 additions and 55 deletions

View File

@@ -114,11 +114,10 @@ export const search =
}; };
export const downloadAirDCPPItem = export const downloadAirDCPPItem =
( (searchInstanceId: Number,
instanceId: string, resultId: String,
resultId: string, comicObjectId: String,
comicObjectId: string, name: String, size: Number, type: any,
comicObject: any,
ADCPPSocket: any, ADCPPSocket: any,
credentials: any, credentials: any,
): void => ): void =>
@@ -133,22 +132,37 @@ export const downloadAirDCPPItem =
} }
let bundleDBImportResult = {}; let bundleDBImportResult = {};
const downloadResult = await ADCPPSocket.post( const downloadResult = await ADCPPSocket.post(
`search/${instanceId}/results/${resultId}/download`, `search/${searchInstanceId}/results/${resultId}/download`,
); );
let bundleId;
let directoryIds;
if (!isNil(downloadResult.bundle_info)) {
bundleId = downloadResult.bundle_info.id;
}
if (!isNil(downloadResult.directory_download_ids)) {
directoryIds = downloadResult.directory_download_ids.map(
(item) => item.id,
);
}
if (!isNil(downloadResult)) { 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) { } catch (error) {
throw error; throw error;

View File

@@ -42,32 +42,7 @@ const AirDCPPSocketComponent = (): ReactElement => {
"queue_bundle_added", "queue_bundle_added",
async (data) => { async (data) => {
console.log("JEMEN:", data); console.log("JEMEN:", data);
const { id, name, size, target, time_added, type } = data;
const downloadResultMetadata = await axios({
method: "POST",
url: `${LIBRARY_SERVICE_BASE_URI}/applyAirDCPPDownloadMetadata`,
headers: {
"Content-Type": "application/json; charset=utf-8",
},
data: {
bundleId: id,
name,
size,
target,
time_added,
type
},
});
// dispatch({
// type: AIRDCPP_RESULT_DOWNLOAD_INITIATED,
// downloadResult: downloadResult,
// bundleDBImportResult,
// });
// dispatch({
// type: IMS_COMIC_BOOK_DB_OBJECT_FETCHED,
// comicBookDetail: bundleDBImportResult.data,
// IMS_inProgress: false,
// });
} }
); );

View File

@@ -18,7 +18,7 @@ import { isEmpty, isNil, map } from "lodash";
import { AirDCPPSocketContext } from "../../context/AirDCPPSocket"; import { AirDCPPSocketContext } from "../../context/AirDCPPSocket";
interface IAcquisitionPanelProps { interface IAcquisitionPanelProps {
query: any; query: any;
comicObjectid: any; comicObjectId: any;
comicObject: any; comicObject: any;
settings: any; settings: any;
} }
@@ -93,13 +93,12 @@ export const AcquisitionPanel = (
// download via AirDC++ // download via AirDC++
const downloadDCPPResult = useCallback( const downloadDCPPResult = useCallback(
(searchInstanceId, resultId, comicBookObjectId, comicObject) => { (searchInstanceId, resultId, name, size, type) => {
dispatch( dispatch(
downloadAirDCPPItem( downloadAirDCPPItem(
searchInstanceId, searchInstanceId, resultId,
resultId, props.comicObjectId,
comicBookObjectId, name, size, type,
comicObject,
airDCPPConfiguration.airDCPPState.socket, airDCPPConfiguration.airDCPPState.socket,
{ {
username: `${airDCPPConfiguration.airDCPPState.settings.directConnect.client.host.username}`, username: `${airDCPPConfiguration.airDCPPState.settings.directConnect.client.host.username}`,
@@ -110,7 +109,7 @@ export const AcquisitionPanel = (
// this is to update the download count badge on the downloads tab // this is to update the download count badge on the downloads tab
dispatch( dispatch(
getBundlesForComic( getBundlesForComic(
comicBookObjectId, props.comicObjectId,
airDCPPConfiguration.airDCPPState.socket, airDCPPConfiguration.airDCPPState.socket,
{ {
username: `${airDCPPConfiguration.airDCPPState.settings.directConnect.client.host.username}`, username: `${airDCPPConfiguration.airDCPPState.settings.directConnect.client.host.username}`,
@@ -245,7 +244,6 @@ export const AcquisitionPanel = (
</thead> </thead>
<tbody> <tbody>
{map(airDCPPSearchResults, ({ result }, idx) => { {map(airDCPPSearchResults, ({ result }, idx) => {
console.log(result);
return ( return (
<tr <tr
key={idx} key={idx}
@@ -302,8 +300,9 @@ export const AcquisitionPanel = (
downloadDCPPResult( downloadDCPPResult(
searchInstance.id, searchInstance.id,
result.id, result.id,
props.comicObjectid, result.name,
props.comicObject, result.size,
result.type,
) )
} }
> >

View File

@@ -182,7 +182,7 @@ export const ComicDetail = (data: ComicDetailProps): ReactElement => {
content: ( content: (
<AcquisitionPanel <AcquisitionPanel
query={airDCPPQuery} query={airDCPPQuery}
comicObjectid={_id} comicObjectId={_id}
comicObject={data.data} comicObject={data.data}
userSettings={userSettings} userSettings={userSettings}
key={4} key={4}

View File

@@ -69,7 +69,24 @@ export const Downloads = (props: IDownloadsProps): ReactElement => {
margin: "0 0 8px 0", margin: "0 0 8px 0",
}} /> }} />
<pre>{JSON.stringify(bundle.acquisition.directconnect.downloads, null, 2)}</pre> <table className="table is-size-7">
<tr>
<th>Name</th>
<th>Size</th>
<th>Type</th>
<th>Bundle ID</th>
</tr>
{bundle.acquisition.directconnect.downloads.map((bundle) => {
return(<tr>
<td>{bundle.name}</td>
<td>{bundle.size}</td>
<td>{bundle.type.str}</td>
<td>{bundle.bundleId}</td>
</tr>)
})}
</table>
{/* <pre>{JSON.stringify(bundle.acquisition.directconnect.downloads, null, 2)}</pre> */}
</> </>
})} })}
</div> </div>