🤼 groundwork for automatcher
This commit is contained in:
@@ -1,8 +1,14 @@
|
|||||||
import axios from "axios";
|
import axios from "axios";
|
||||||
import { IFolderData } from "../../server/interfaces/folder.interface";
|
import {
|
||||||
import { API_BASE_URI } from "../constants/endpoints";
|
IFolderData,
|
||||||
|
IExtractedComicBookCoverFile,
|
||||||
|
} from "../../server/interfaces/folder.interface";
|
||||||
|
import { API_BASE_URI, SOCKET_BASE_URI } from "../constants/endpoints";
|
||||||
import { io } from "socket.io-client";
|
import { io } from "socket.io-client";
|
||||||
import { IMS_SOCKET_DATA_FETCHED } from "../constants/action-types";
|
import {
|
||||||
|
IMS_SOCKET_DATA_FETCHED,
|
||||||
|
IMS_SOCKET_CONNECTION_CONNECTED,
|
||||||
|
} from "../constants/action-types";
|
||||||
|
|
||||||
export async function walkFolder(path: string): Promise<Array<IFolderData>> {
|
export async function walkFolder(path: string): Promise<Array<IFolderData>> {
|
||||||
return axios
|
return axios
|
||||||
@@ -33,12 +39,15 @@ export const fetchComicBookMetadata = (options) => async (dispatch) => {
|
|||||||
};
|
};
|
||||||
const walkedFolders = await walkFolder("./comics");
|
const walkedFolders = await walkFolder("./comics");
|
||||||
|
|
||||||
const socket = io("ws://localhost:3000/", {
|
const socket = io(SOCKET_BASE_URI, {
|
||||||
reconnectionDelayMax: 10000,
|
reconnectionDelayMax: 10000,
|
||||||
});
|
});
|
||||||
|
|
||||||
socket.on("connect", () => {
|
socket.on("connect", () => {
|
||||||
console.log(`connect ${socket.id}`);
|
console.log(`connect ${socket.id}`);
|
||||||
|
dispatch({
|
||||||
|
type: IMS_SOCKET_CONNECTION_CONNECTED,
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
socket.on("disconnect", () => {
|
socket.on("disconnect", () => {
|
||||||
@@ -53,7 +62,7 @@ export const fetchComicBookMetadata = (options) => async (dispatch) => {
|
|||||||
opts: { garam: "pasha" },
|
opts: { garam: "pasha" },
|
||||||
});
|
});
|
||||||
|
|
||||||
socket.on("comicBookCoverMetadata", (data) => {
|
socket.on("comicBookCoverMetadata", (data: IExtractedComicBookCoverFile) => {
|
||||||
dispatch({
|
dispatch({
|
||||||
type: IMS_SOCKET_DATA_FETCHED,
|
type: IMS_SOCKET_DATA_FETCHED,
|
||||||
data,
|
data,
|
||||||
@@ -61,5 +70,3 @@ export const fetchComicBookMetadata = (options) => async (dispatch) => {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
export const validate = (object) => {};
|
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
export const COMICBOOKINFO_SERVICE_URI =
|
export const COMICBOOKINFO_SERVICE_URI =
|
||||||
"http://localhost:6050/api/comicbookinfo/";
|
"http://localhost:6050/api/comicbookinfo/";
|
||||||
export const API_BASE_URI = "http://localhost:8050/api/";
|
export const API_BASE_URI = "http://localhost:8050/api/";
|
||||||
|
export const SOCKET_BASE_URI = "ws://localhost:3000/";
|
||||||
|
|||||||
@@ -44,8 +44,8 @@ export function tokenize(inputString) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export function refineQuery(queryString) {
|
export function refineQuery(queryString) {
|
||||||
let queryObj = tokenize(queryString);
|
const queryObj = tokenize(queryString);
|
||||||
let removedYears = _.xor(
|
const removedYears = _.xor(
|
||||||
queryObj.sentences.normalized,
|
queryObj.sentences.normalized,
|
||||||
queryObj.years.yearMatches,
|
queryObj.years.yearMatches,
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -1,52 +0,0 @@
|
|||||||
import { walkFolder } from "../actions/fileops.actions";
|
|
||||||
import { io } from "socket.io-client";
|
|
||||||
import { IMS_SOCKET_DATA_FETCHED } from "../constants/action-types";
|
|
||||||
|
|
||||||
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) => {
|
|
||||||
console.log(data);
|
|
||||||
dispatch({
|
|
||||||
type: IMS_SOCKET_DATA_FETCHED,
|
|
||||||
comicBookMetadata: data,
|
|
||||||
dataTransferred: true,
|
|
||||||
});
|
|
||||||
});
|
|
||||||
};
|
|
||||||
0
src/client/workers/test.worker.ts
Normal file
0
src/client/workers/test.worker.ts
Normal file
Reference in New Issue
Block a user