diff --git a/src/client/actions/fileops.actions.tsx b/src/client/actions/fileops.actions.tsx index 86c79c0..7102054 100644 --- a/src/client/actions/fileops.actions.tsx +++ b/src/client/actions/fileops.actions.tsx @@ -1,6 +1,8 @@ import axios from "axios"; import { IFolderData } from "../../server/interfaces/folder.interface"; import { API_BASE_URI } from "../constants/endpoints"; +import { io } from "socket.io-client"; +import { IMS_SOCKET_DATA_FETCHED } from "../constants/action-types"; export async function walkFolder(path: string): Promise> { return axios @@ -17,3 +19,51 @@ export async function walkFolder(path: string): Promise> { return data; }); } + +export const fetchComicBookMetadata = (options) => async (dispatch) => { + console.log(options); + const targetOptions = { + sourceFolder: options, + extractTarget: "cover", + targetExtractionFolder: "./userdata/covers", + extractionMode: "bulk", + }; + + const pagingConfig = { + pageLimit: 25, + page: 1, + }; + const extractionOptions = { + ...targetOptions, + paginationOptions: pagingConfig, + }; + const walkedFolders = await walkFolder("./comics"); + + const socket = io("ws://localhost:3000/", { + reconnectionDelayMax: 10000, + }); + + socket.on("connect", () => { + console.log(`connect ${socket.id}`); + }); + + socket.on("disconnect", () => { + console.log(`disconnect`); + }); + socket.emit("call", { + action: "getComicCovers", + params: { + extractionOptions, + walkedFolders, + }, + opts: { garam: "pasha" }, + }); + + socket.on("comicBookCoverMetadata", (data) => { + dispatch({ + type: IMS_SOCKET_DATA_FETCHED, + data, + dataTransferred: true, + }); + }); +}; diff --git a/src/client/components/App.tsx b/src/client/components/App.tsx index 8974b4f..2cf5247 100644 --- a/src/client/components/App.tsx +++ b/src/client/components/App.tsx @@ -18,7 +18,7 @@ class App extends React.Component, undefined> { - + diff --git a/src/client/components/Import.tsx b/src/client/components/Import.tsx index dc6d664..77b5e8e 100644 --- a/src/client/components/Import.tsx +++ b/src/client/components/Import.tsx @@ -1,13 +1,18 @@ import * as React from "react"; import _ from "lodash"; import { connect } from "react-redux"; -import { greet } from "../workers/extractCovers.worker"; +import { fetchComicBookMetadata } from "../actions/fileops.actions"; +import { IFolderData } from "../shared/interfaces/comicinfo.interfaces"; interface IProps { matches: unknown; + fetchComicMetadata: any; + path: string; + garam: any; } interface IState { folderWalkResults?: Array; searchPaneIndex: number; + fileOps: any; } class Import extends React.Component { @@ -25,9 +30,12 @@ class Import extends React.Component { }); } - public async startFolderWalk() { - console.log(await greet("./comics")); + public componentDidMount() { + if (typeof this.props.path !== "undefined") { + this.props.fetchComicMetadata(); + } } + public render() { return (
@@ -53,10 +61,7 @@ class Import extends React.Component {

-