🔬 Wiring up the image analysis UI with the endpoint

This commit is contained in:
2022-02-08 14:48:24 -08:00
parent 8fdd8d0226
commit 9ff048d541
13 changed files with 214 additions and 85 deletions

View File

@@ -1,6 +1,6 @@
import axios from "axios";
import rateLimiter from "axios-rate-limit";
import { map } from "lodash";
import qs from "qs";
import { IExtractionOptions } from "threetwo-ui-typings";
import {
@@ -9,8 +9,6 @@ import {
CV_API_GENERIC_FAILURE,
IMS_COMIC_BOOK_DB_OBJECT_CALL_IN_PROGRESS,
IMS_COMIC_BOOK_DB_OBJECT_FETCHED,
IMS_COMIC_BOOK_ARCHIVE_EXTRACTION_SUCCESS,
IMS_COMIC_BOOK_ARCHIVE_EXTRACTION_CALL_IN_PROGRESS,
CV_ISSUES_METADATA_CALL_IN_PROGRESS,
CV_CLEANUP,
IMS_COMIC_BOOKS_DB_OBJECTS_FETCHED,
@@ -175,39 +173,3 @@ export const applyComicVineMatch =
IMS_inProgress: false,
});
};
export const extractComicArchive =
(path: string, options: IExtractionOptions) => async (dispatch) => {
const comicBookPages: string[] = [];
dispatch({
type: IMS_COMIC_BOOK_ARCHIVE_EXTRACTION_CALL_IN_PROGRESS,
});
const extractedComicBookArchive = await axios({
method: "POST",
url: `${LIBRARY_SERVICE_BASE_URI}/unrarArchive`,
headers: {
"Content-Type": "application/json; charset=utf-8",
},
data: {
options,
filePath: path,
},
});
map(extractedComicBookArchive.data, (page) => {
const foo = page.path.split("/");
const folderName = foo[foo.length - 1];
const imagePath = encodeURI(
`${LIBRARY_SERVICE_BASE_URI}/userdata/expanded/` +
folderName +
`/` +
page.name +
page.extension,
);
comicBookPages.push(imagePath);
});
console.log(comicBookPages);
dispatch({
type: IMS_COMIC_BOOK_ARCHIVE_EXTRACTION_SUCCESS,
extractedComicBookArchive: comicBookPages,
});
};