⏯ Added queue pause/resume controls in UI

This commit is contained in:
2022-03-17 17:06:13 -07:00
parent f28fbfa938
commit f6ca91f530
4 changed files with 36 additions and 5 deletions

View File

@@ -28,6 +28,7 @@ import {
SS_SEARCH_IN_PROGRESS,
FILEOPS_STATE_RESET,
LS_IMPORT_CALL_IN_PROGRESS,
LS_TOGGLE_IMPORT_QUEUE,
} from "../constants/action-types";
import { success } from "react-notification-system-redux";
import { isNil, map } from "lodash";
@@ -88,7 +89,13 @@ export const fetchComicBookMetadata = (options) => async (dispatch) => {
data: { extractionOptions },
});
};
export const toggleImportQueueStatus = (options) => async (dispatch) => {
dispatch({
type: LS_TOGGLE_IMPORT_QUEUE,
meta: { remote: true },
data: { manjhul: "jigyadam", action: options.action },
});
};
export const getComicBooks = (options) => async (dispatch) => {
const { paginationOptions, predicate, comicStatus } = options;

View File

@@ -1,7 +1,9 @@
import React, { ReactElement, useCallback, useContext } from "react";
import { isEmpty } from "lodash";
import React, { ReactElement, useCallback, useContext, useState } from "react";
import { useSelector, useDispatch } from "react-redux";
import { fetchComicBookMetadata } from "../actions/fileops.actions";
import {
fetchComicBookMetadata,
toggleImportQueueStatus,
} from "../actions/fileops.actions";
import DynamicList, { createCache } from "react-window-dynamic-list";
import "react-loader-spinner/dist/loader/css/react-spinner-loader.css";
import Loader from "react-loader-spinner";
@@ -34,12 +36,22 @@ export const Import = (props: IProps): ReactElement => {
const libraryQueueImportStatus = useSelector(
(state: RootState) => state.fileOps.IMSCallInProgress,
);
const [isImportQueuePaused, setImportQueueStatus] = useState(false);
const initiateImport = useCallback(() => {
if (typeof props.path !== "undefined") {
dispatch(fetchComicBookMetadata(props.path));
}
}, [dispatch]);
const toggleImport = useCallback(() => {
setImportQueueStatus(!isImportQueuePaused);
if (isImportQueuePaused === false) {
dispatch(toggleImportQueueStatus({ action: "resume" }));
} else if (isImportQueuePaused === true) {
dispatch(toggleImportQueueStatus({ action: "pause" }));
}
}, [isImportQueuePaused]);
return (
<div className="container">
<section className="section is-small">
@@ -86,6 +98,9 @@ export const Import = (props: IProps): ReactElement => {
</p>
<pre>{JSON.stringify(libraryQueueResults, null, 2)}</pre>
<button className="button is-warning" onClick={toggleImport}>
Pause Queue
</button>
</section>
</div>
);

View File

@@ -12,6 +12,8 @@ export const IMS_RAW_IMPORT_FAILED = "IMS_RAW_IMPORT_FAILED";
// Library service generic action types
export const LS_IMPORT_CALL_IN_PROGRESS = "LS_IMPORT_CALL_IN_PROGRESS";
// Library import bull mq queue control
export const LS_TOGGLE_IMPORT_QUEUE = "LS_TOGGLE_IMPORT_QUEUE";
// ComicVine Metadata
export const IMS_CV_METADATA_IMPORT_CALL_IN_PROGRESS =