📝 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 =
(
instanceId: string,
resultId: string,
comicObjectId: string,
comicObject: any,
(searchInstanceId: Number,
resultId: String,
comicObjectId: String,
name: String, size: Number, type: any,
ADCPPSocket: any,
credentials: any,
): void =>
@@ -133,22 +132,37 @@ export const downloadAirDCPPItem =
}
let bundleDBImportResult = {};
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)) {
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;

View File

@@ -42,32 +42,7 @@ const AirDCPPSocketComponent = (): ReactElement => {
"queue_bundle_added",
async (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";
interface IAcquisitionPanelProps {
query: any;
comicObjectid: any;
comicObjectId: any;
comicObject: any;
settings: any;
}
@@ -93,13 +93,12 @@ export const AcquisitionPanel = (
// download via AirDC++
const downloadDCPPResult = useCallback(
(searchInstanceId, resultId, comicBookObjectId, comicObject) => {
(searchInstanceId, resultId, name, size, type) => {
dispatch(
downloadAirDCPPItem(
searchInstanceId,
resultId,
comicBookObjectId,
comicObject,
searchInstanceId, resultId,
props.comicObjectId,
name, size, type,
airDCPPConfiguration.airDCPPState.socket,
{
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
dispatch(
getBundlesForComic(
comicBookObjectId,
props.comicObjectId,
airDCPPConfiguration.airDCPPState.socket,
{
username: `${airDCPPConfiguration.airDCPPState.settings.directConnect.client.host.username}`,
@@ -245,7 +244,6 @@ export const AcquisitionPanel = (
</thead>
<tbody>
{map(airDCPPSearchResults, ({ result }, idx) => {
console.log(result);
return (
<tr
key={idx}
@@ -302,8 +300,9 @@ export const AcquisitionPanel = (
downloadDCPPResult(
searchInstance.id,
result.id,
props.comicObjectid,
props.comicObject,
result.name,
result.size,
result.type,
)
}
>

View File

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

View File

@@ -69,7 +69,24 @@ export const Downloads = (props: IDownloadsProps): ReactElement => {
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>