🔧 Support for refactored import process WIP

This commit is contained in:
2021-12-01 14:06:41 -08:00
parent 2cc9aee22e
commit e197143498
11 changed files with 67 additions and 25 deletions

View File

@@ -59,7 +59,7 @@ export const fetchComicBookMetadata = (options) => async (dispatch) => {
page: 1, page: 1,
}, },
}; };
const walked = await walkFolder("./comics");
// dispatch( // dispatch(
// success({ // success({
// // uid: 'once-please', // you can specify your own uid if required // // uid: 'once-please', // you can specify your own uid if required
@@ -70,13 +70,11 @@ export const fetchComicBookMetadata = (options) => async (dispatch) => {
// autoDismiss: 0, // autoDismiss: 0,
// }), // }),
// ); // );
walked.forEach((walkedFolders) => dispatch({
dispatch({ type: LS_IMPORT,
type: LS_IMPORT, meta: { remote: true },
meta: { remote: true }, data: { extractionOptions },
data: { extractionOptions, walkedFolders }, });
}),
);
}; };
export const getComicBooks = (options) => async (dispatch) => { export const getComicBooks = (options) => async (dispatch) => {

View File

@@ -46,3 +46,7 @@ export const deleteSettings = () => async (dispatch) => {
}); });
} }
}; };
export const flushDb = () => async (dispatch) => {
}

View File

@@ -11,6 +11,7 @@ export const AirDCPPHubsForm = (airDCPPClientUserSettings): ReactElement => {
const dispatch = useDispatch(); const dispatch = useDispatch();
const [hubList, setHubList] = useState([]); const [hubList, setHubList] = useState([]);
const { ADCPPSocket } = useContext(AirDCPPSocketContext); const { ADCPPSocket } = useContext(AirDCPPSocketContext);
useEffect(() => { useEffect(() => {
(async () => { (async () => {
if (!isEmpty(settings)) { if (!isEmpty(settings)) {

View File

@@ -7,7 +7,6 @@ import axios from "axios";
import { AirDCPPSocketContext } from "../../context/AirDCPPSocket"; import { AirDCPPSocketContext } from "../../context/AirDCPPSocket";
import AirDCPPSocket from "../../services/DcppSearchService"; import AirDCPPSocket from "../../services/DcppSearchService";
import { isUndefined, isEmpty, isNil } from "lodash"; import { isUndefined, isEmpty, isNil } from "lodash";
import { CORS_PROXY_SERVER_URI } from "../../constants/endpoints";
export const AirDCPPSettingsForm = (airDCPPClientSettings): ReactElement => { export const AirDCPPSettingsForm = (airDCPPClientSettings): ReactElement => {
const { settings } = airDCPPClientSettings; const { settings } = airDCPPClientSettings;

View File

@@ -490,8 +490,7 @@ export const ComicDetail = ({}: ComicDetailProps): ReactElement => {
let comicBookTitle = ""; let comicBookTitle = "";
if (!isNil(comicBookDetailData.rawFileDetails)) { if (!isNil(comicBookDetailData.rawFileDetails)) {
const encodedFilePath = encodeURI( const encodedFilePath = encodeURI(
`${IMPORT_SERVICE_HOST}` + `${IMPORT_SERVICE_HOST}/${comicBookDetailData.rawFileDetails.cover.filePath}`,
removeLeadingPeriod(comicBookDetailData.rawFileDetails.path),
); );
imagePath = escapePoundSymbol(encodedFilePath); imagePath = escapePoundSymbol(encodedFilePath);
comicBookTitle = comicBookDetailData.rawFileDetails.name; comicBookTitle = comicBookDetailData.rawFileDetails.name;

View File

@@ -42,7 +42,7 @@ export const Library = ({}: IComicBookLibraryProps): ReactElement => {
const RawFileDetails = ({ value }) => { const RawFileDetails = ({ value }) => {
if (!isNil(value.path)) { if (!isNil(value.path)) {
const encodedFilePath = encodeURI( const encodedFilePath = encodeURI(
`${IMPORT_SERVICE_HOST}` + removeLeadingPeriod(value.path), `${IMPORT_SERVICE_HOST}/${value.cover.filePath}`,
); );
const filePath = escapePoundSymbol(encodedFilePath); const filePath = escapePoundSymbol(encodedFilePath);
return ( return (
@@ -257,6 +257,9 @@ export const Library = ({}: IComicBookLibraryProps): ReactElement => {
RawFileDetails.propTypes = { RawFileDetails.propTypes = {
value: PropTypes.shape({ value: PropTypes.shape({
cover: PropTypes.shape({
filePath: PropTypes.string,
}),
name: PropTypes.string, name: PropTypes.string,
path: PropTypes.string, path: PropTypes.string,
fileSize: PropTypes.number, fileSize: PropTypes.number,

View File

@@ -41,8 +41,7 @@ export const RecentlyImported = ({
let comicName = ""; let comicName = "";
if (!isNil(rawFileDetails)) { if (!isNil(rawFileDetails)) {
const encodedFilePath = encodeURI( const encodedFilePath = encodeURI(
`${IMPORT_SERVICE_HOST}` + `${IMPORT_SERVICE_HOST}/${rawFileDetails.cover.filePath}`,
removeLeadingPeriod(rawFileDetails.path),
); );
imagePath = escapePoundSymbol(encodedFilePath); imagePath = escapePoundSymbol(encodedFilePath);
comicName = rawFileDetails.name; comicName = rawFileDetails.name;
@@ -77,11 +76,11 @@ export const RecentlyImported = ({
)} )}
{/* Issue type */} {/* Issue type */}
{!isUndefined(sourcedMetadata.comicvine) && {!isUndefined(sourcedMetadata.comicvine) &&
!isNil( !isNil(
detectIssueTypes( detectIssueTypes(
sourcedMetadata.comicvine.volumeInformation.description, sourcedMetadata.comicvine.volumeInformation.description,
), ),
) ? ( ) ? (
<span className="tag is-warning"> <span className="tag is-warning">
{ {
detectIssueTypes( detectIssueTypes(

View File

@@ -1,9 +1,48 @@
import React, { ReactElement } from "react"; import React, { ReactElement, useCallback } from "react";
import { flushDb } from "../../actions/settings.actions";
export const SystemSettingsForm = (settingsObject): ReactElement => { export const SystemSettingsForm = (settingsObject): ReactElement => {
const { settings } = settingsObject; const { settings } = settingsObject;
return <div className="mt-4 is-clearfix"></div>; // const flushDb = useC
return (
<div className="is-clearfix">
<div className="mt-4">
<h3 className="title">Flush DB and Temporary Folders</h3>
<h6 className="subtitle has-text-grey-light">
If you are encountering issues, start over using this functionality.
</h6>
<article className="message is-danger">
<div className="message-body is-size-6 is-family-secondary">
Flushing and resetting will clear out:
<ol>
<li>The mongo collection that holds library metadata</li>
<li>
Your <code>USERDATA_DIRECTORY</code> which includes
<code>covers</code>, <code>temporary</code> and
<code>expanded</code> subfolders.
</li>
</ol>
</div>
</article>
<article className="message is-info">
<div className="message-body is-size-6 is-family-secondary">
Your comic book files are not touched, and your settings will remain
intact.
</div>
</article>
<button className="button is-danger" onClick={flushDb}>
<span className="icon">
<i className="fas fa-eraser"></i>
</span>
<span>Flush DB & Temporary Folders</span>
</button>
</div>
</div>
);
}; };
export default SystemSettingsForm; export default SystemSettingsForm;

View File

@@ -51,7 +51,7 @@ export const SETTINGS_SERVICE_BASE_URI = hostURIBuilder({
}); });
export const SOCKET_BASE_URI = hostURIBuilder({ export const SOCKET_BASE_URI = hostURIBuilder({
protocol: "http", protocol: "ws",
host: process.env.UNDERLYING_HOSTNAME || "localhost", host: process.env.UNDERLYING_HOSTNAME || "localhost",
port: "3001", port: "3001",
apiPath: `/`, apiPath: `/`,

View File

@@ -7,7 +7,7 @@ import { io } from "socket.io-client";
import socketIoMiddleware from "redux-socket.io-middleware"; import socketIoMiddleware from "redux-socket.io-middleware";
import { SOCKET_BASE_URI } from "../constants/endpoints"; import { SOCKET_BASE_URI } from "../constants/endpoints";
const socketConnection = io(SOCKET_BASE_URI); const socketConnection = io(SOCKET_BASE_URI, { transports: ["websocket"] });
export const history = createBrowserHistory(); export const history = createBrowserHistory();
const configureStore = (initialState) => { const configureStore = (initialState) => {

View File

@@ -30,8 +30,8 @@ app.use(bodyParser.urlencoded({ extended: true }));
// REGISTER ROUTES // REGISTER ROUTES
// all of the routes will be prefixed with /api // all of the routes will be prefixed with /api
// const routes: Router[] = Object.values(router); const routes: Router[] = Object.values(router);
// app.use("/api", routes); app.use("/api", routes);
// Send index.html on root request // Send index.html on root request
app.use(express.static("dist")); app.use(express.static("dist"));