⏯ Added queue pause/resume controls in UI
This commit is contained in:
@@ -28,6 +28,7 @@ import {
|
|||||||
SS_SEARCH_IN_PROGRESS,
|
SS_SEARCH_IN_PROGRESS,
|
||||||
FILEOPS_STATE_RESET,
|
FILEOPS_STATE_RESET,
|
||||||
LS_IMPORT_CALL_IN_PROGRESS,
|
LS_IMPORT_CALL_IN_PROGRESS,
|
||||||
|
LS_TOGGLE_IMPORT_QUEUE,
|
||||||
} from "../constants/action-types";
|
} from "../constants/action-types";
|
||||||
import { success } from "react-notification-system-redux";
|
import { success } from "react-notification-system-redux";
|
||||||
import { isNil, map } from "lodash";
|
import { isNil, map } from "lodash";
|
||||||
@@ -88,7 +89,13 @@ export const fetchComicBookMetadata = (options) => async (dispatch) => {
|
|||||||
data: { extractionOptions },
|
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) => {
|
export const getComicBooks = (options) => async (dispatch) => {
|
||||||
const { paginationOptions, predicate, comicStatus } = options;
|
const { paginationOptions, predicate, comicStatus } = options;
|
||||||
|
|
||||||
|
|||||||
@@ -1,7 +1,9 @@
|
|||||||
import React, { ReactElement, useCallback, useContext } from "react";
|
import React, { ReactElement, useCallback, useContext, useState } from "react";
|
||||||
import { isEmpty } from "lodash";
|
|
||||||
import { useSelector, useDispatch } from "react-redux";
|
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 DynamicList, { createCache } from "react-window-dynamic-list";
|
||||||
import "react-loader-spinner/dist/loader/css/react-spinner-loader.css";
|
import "react-loader-spinner/dist/loader/css/react-spinner-loader.css";
|
||||||
import Loader from "react-loader-spinner";
|
import Loader from "react-loader-spinner";
|
||||||
@@ -34,12 +36,22 @@ export const Import = (props: IProps): ReactElement => {
|
|||||||
const libraryQueueImportStatus = useSelector(
|
const libraryQueueImportStatus = useSelector(
|
||||||
(state: RootState) => state.fileOps.IMSCallInProgress,
|
(state: RootState) => state.fileOps.IMSCallInProgress,
|
||||||
);
|
);
|
||||||
|
const [isImportQueuePaused, setImportQueueStatus] = useState(false);
|
||||||
const initiateImport = useCallback(() => {
|
const initiateImport = useCallback(() => {
|
||||||
if (typeof props.path !== "undefined") {
|
if (typeof props.path !== "undefined") {
|
||||||
dispatch(fetchComicBookMetadata(props.path));
|
dispatch(fetchComicBookMetadata(props.path));
|
||||||
}
|
}
|
||||||
}, [dispatch]);
|
}, [dispatch]);
|
||||||
|
|
||||||
|
const toggleImport = useCallback(() => {
|
||||||
|
setImportQueueStatus(!isImportQueuePaused);
|
||||||
|
if (isImportQueuePaused === false) {
|
||||||
|
dispatch(toggleImportQueueStatus({ action: "resume" }));
|
||||||
|
} else if (isImportQueuePaused === true) {
|
||||||
|
dispatch(toggleImportQueueStatus({ action: "pause" }));
|
||||||
|
}
|
||||||
|
}, [isImportQueuePaused]);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="container">
|
<div className="container">
|
||||||
<section className="section is-small">
|
<section className="section is-small">
|
||||||
@@ -86,6 +98,9 @@ export const Import = (props: IProps): ReactElement => {
|
|||||||
</p>
|
</p>
|
||||||
|
|
||||||
<pre>{JSON.stringify(libraryQueueResults, null, 2)}</pre>
|
<pre>{JSON.stringify(libraryQueueResults, null, 2)}</pre>
|
||||||
|
<button className="button is-warning" onClick={toggleImport}>
|
||||||
|
Pause Queue
|
||||||
|
</button>
|
||||||
</section>
|
</section>
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -12,6 +12,8 @@ export const IMS_RAW_IMPORT_FAILED = "IMS_RAW_IMPORT_FAILED";
|
|||||||
|
|
||||||
// Library service generic action types
|
// Library service generic action types
|
||||||
export const LS_IMPORT_CALL_IN_PROGRESS = "LS_IMPORT_CALL_IN_PROGRESS";
|
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
|
// ComicVine Metadata
|
||||||
export const IMS_CV_METADATA_IMPORT_CALL_IN_PROGRESS =
|
export const IMS_CV_METADATA_IMPORT_CALL_IN_PROGRESS =
|
||||||
|
|||||||
@@ -990,13 +990,20 @@
|
|||||||
core-js-pure "^3.20.2"
|
core-js-pure "^3.20.2"
|
||||||
regenerator-runtime "^0.13.4"
|
regenerator-runtime "^0.13.4"
|
||||||
|
|
||||||
"@babel/runtime@^7.0.0", "@babel/runtime@^7.10.0", "@babel/runtime@^7.10.2", "@babel/runtime@^7.12.0", "@babel/runtime@^7.12.1", "@babel/runtime@^7.13.10", "@babel/runtime@^7.13.17", "@babel/runtime@^7.15.4", "@babel/runtime@^7.16.3", "@babel/runtime@^7.16.5", "@babel/runtime@^7.5.5", "@babel/runtime@^7.7.6", "@babel/runtime@^7.8.4", "@babel/runtime@^7.8.7", "@babel/runtime@^7.9.2":
|
"@babel/runtime@^7.0.0", "@babel/runtime@^7.10.0", "@babel/runtime@^7.10.2", "@babel/runtime@^7.12.0", "@babel/runtime@^7.12.1", "@babel/runtime@^7.13.10", "@babel/runtime@^7.13.17", "@babel/runtime@^7.15.4", "@babel/runtime@^7.16.3", "@babel/runtime@^7.5.5", "@babel/runtime@^7.7.6", "@babel/runtime@^7.8.4", "@babel/runtime@^7.8.7", "@babel/runtime@^7.9.2":
|
||||||
version "7.16.7"
|
version "7.16.7"
|
||||||
resolved "https://registry.yarnpkg.com/@babel/runtime/-/runtime-7.16.7.tgz#03ff99f64106588c9c403c6ecb8c3bafbbdff1fa"
|
resolved "https://registry.yarnpkg.com/@babel/runtime/-/runtime-7.16.7.tgz#03ff99f64106588c9c403c6ecb8c3bafbbdff1fa"
|
||||||
integrity sha512-9E9FJowqAsytyOY6LG+1KuueckRL+aQW+mKvXRXnuFGyRAyepJPmEo9vgMfXUA6O9u3IeEdv9MAkppFcaQwogQ==
|
integrity sha512-9E9FJowqAsytyOY6LG+1KuueckRL+aQW+mKvXRXnuFGyRAyepJPmEo9vgMfXUA6O9u3IeEdv9MAkppFcaQwogQ==
|
||||||
dependencies:
|
dependencies:
|
||||||
regenerator-runtime "^0.13.4"
|
regenerator-runtime "^0.13.4"
|
||||||
|
|
||||||
|
"@babel/runtime@^7.16.5":
|
||||||
|
version "7.17.7"
|
||||||
|
resolved "https://registry.yarnpkg.com/@babel/runtime/-/runtime-7.17.7.tgz#a5f3328dc41ff39d803f311cfe17703418cf9825"
|
||||||
|
integrity sha512-L6rvG9GDxaLgFjg41K+5Yv9OMrU98sWe+Ykmc6FDJW/+vYZMhdOMKkISgzptMaERHvS2Y2lw9MDRm2gHhlQQoA==
|
||||||
|
dependencies:
|
||||||
|
regenerator-runtime "^0.13.4"
|
||||||
|
|
||||||
"@babel/template@^7.16.7", "@babel/template@^7.3.3":
|
"@babel/template@^7.16.7", "@babel/template@^7.3.3":
|
||||||
version "7.16.7"
|
version "7.16.7"
|
||||||
resolved "https://registry.yarnpkg.com/@babel/template/-/template-7.16.7.tgz#8d126c8701fde4d66b264b3eba3d96f07666d155"
|
resolved "https://registry.yarnpkg.com/@babel/template/-/template-7.16.7.tgz#8d126c8701fde4d66b264b3eba3d96f07666d155"
|
||||||
|
|||||||
Reference in New Issue
Block a user