From 05fb0fad2be3111c7cd5d2767e0929561a68723f Mon Sep 17 00:00:00 2001 From: Rishi Ghan Date: Wed, 4 Aug 2021 15:46:41 -0700 Subject: [PATCH] =?UTF-8?q?=F0=9F=93=9D=20Refactoring?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- package.json | 2 +- src/client/actions/fileops.actions.tsx | 7 +++-- src/client/assets/scss/App.scss | 27 ++++++++++++---- src/client/components/Dashboard.tsx | 4 +-- src/client/components/Library.tsx | 31 +++++++++++++++---- .../shared/utils/filenameparser.utils.ts | 8 ++--- yarn.lock | 8 ++--- 7 files changed, 60 insertions(+), 27 deletions(-) diff --git a/package.json b/package.json index b90fdbd..0818d79 100644 --- a/package.json +++ b/package.json @@ -55,7 +55,7 @@ "react-window-dynamic-list": "^2.3.5", "sharp": "^0.28.1", "socket.io-client": "^4.1.2", - "threetwo-ui-typings": "^1.0.1", + "threetwo-ui-typings": "^1.0.2", "voca": "^1.4.0", "websocket": "^1.0.34", "ws": "^7.5.3", diff --git a/src/client/actions/fileops.actions.tsx b/src/client/actions/fileops.actions.tsx index 3a754cb..746505e 100644 --- a/src/client/actions/fileops.actions.tsx +++ b/src/client/actions/fileops.actions.tsx @@ -71,7 +71,7 @@ export const fetchComicBookMetadata = (options) => async (dispatch) => { socket.on("disconnect", () => { console.log(`disconnect`); }); - socket.emit("importComicsInDB", { + socket.emit("importComicsToDB", { action: "getComicCovers", params: { extractionOptions, @@ -80,6 +80,7 @@ export const fetchComicBookMetadata = (options) => async (dispatch) => { }); socket.on("comicBookCoverMetadata", (data: IExtractedComicBookCoverFile) => { + console.log("Recd cover"); dispatch({ type: IMS_COMICBOOK_METADATA_FETCHED, data, @@ -88,11 +89,11 @@ export const fetchComicBookMetadata = (options) => async (dispatch) => { }); }; -export const getRecentlyImportedComicBooks = (options) => async (dispatch) => { +export const getComicBooks = (options) => async (dispatch) => { const { paginationOptions } = options; return axios .request({ - url: "http://localhost:3000/api/import/getRecentlyImportedComicBooks", + url: "http://localhost:3000/api/import/getComicBooks", method: "POST", data: { paginationOptions, diff --git a/src/client/assets/scss/App.scss b/src/client/assets/scss/App.scss index f4d5067..6387238 100644 --- a/src/client/assets/scss/App.scss +++ b/src/client/assets/scss/App.scss @@ -59,7 +59,6 @@ $border-color: red; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); column-gap: 0.5em; row-gap: 1.2em; - min-height: 30px; .card { max-width: 500px; @@ -76,12 +75,11 @@ $border-color: red; align-self: center; .image { max-width: 60px; - border-top-right-radius: 0; - border-bottom-right-radius: 0; - border-top-left-radius: 0.25em; - border-bottom-left-radius: 0.25em; + border-top-right-radius: 0; + border-bottom-right-radius: 0; + border-top-left-radius: 0.25em; + border-bottom-left-radius: 0.25em; } - } .card-content { align-self: center; @@ -111,6 +109,23 @@ $border-color: red; } } +// Library +.library { + table { + td { + border: 0 none; + .card { + .name { + margin: 0 0 4px 0; + } + } + } + tbody { + padding: 10px 0 0 0; + } + } +} + .comic-vine-match-drawer { // comic detail drawer .search-criteria-card { diff --git a/src/client/components/Dashboard.tsx b/src/client/components/Dashboard.tsx index 74f6a97..8ff10f9 100644 --- a/src/client/components/Dashboard.tsx +++ b/src/client/components/Dashboard.tsx @@ -2,7 +2,7 @@ import * as React from "react"; import { connect } from "react-redux"; import ZeroState from "./ZeroState"; import { RecentlyImported } from "./RecentlyImported"; -import { getRecentlyImportedComicBooks } from "../actions/fileops.actions"; +import { getComicBooks } from "../actions/fileops.actions"; import { isEmpty } from "lodash"; interface IProps { @@ -52,7 +52,7 @@ function mapStateToProps(state: IState) { const mapDispatchToProps = (dispatch) => ({ getRecentComics() { dispatch( - getRecentlyImportedComicBooks({ + getComicBooks({ paginationOptions: { page: 0, limit: 5, diff --git a/src/client/components/Library.tsx b/src/client/components/Library.tsx index 2c22672..8f3899e 100644 --- a/src/client/components/Library.tsx +++ b/src/client/components/Library.tsx @@ -11,6 +11,7 @@ import { } from "../shared/utils/formatting.utils"; import { useTable } from "react-table"; import prettyBytes from "pretty-bytes"; +import ellipsize from "ellipsize"; import { useDispatch, useSelector } from "react-redux"; @@ -47,9 +48,19 @@ export const Library = ({}: IComicBookLibraryProps): ReactElement => { @@ -60,7 +71,12 @@ export const Library = ({}: IComicBookLibraryProps): ReactElement => { { Header: "Import Status", accessor: "importStatus.isImported", - Cell: (props) => `${props.cell.value.toString()}`, + Cell: (props) => + `${props.cell.value.toString()}` ? ( + Imported + ) : ( + "Not Imported" + ), }, ], }, @@ -77,8 +93,11 @@ export const Library = ({}: IComicBookLibraryProps): ReactElement => {

Library

-
- +
+
{headerGroups.map((headerGroup, idx) => ( diff --git a/src/client/shared/utils/filenameparser.utils.ts b/src/client/shared/utils/filenameparser.utils.ts index 8af30d8..135c4c3 100644 --- a/src/client/shared/utils/filenameparser.utils.ts +++ b/src/client/shared/utils/filenameparser.utils.ts @@ -48,14 +48,12 @@ export const preprocess = (inputString: string) => { // see if the comic matches the following format, and if so, remove everything // after the first number: // "nnn series name #xx (etc) (etc)" -> "series name #xx (etc) (etc)" - const format1 = "124 series name #xx (etc) (etc)".match( - /^\s*(\d+)[\s._-]+?([^#]+)(\W+.*)/, - ); + const format1 = inputString.match(/^\s*(\d+)[\s._-]+?([^#]+)(\W+.*)/); // see if the comic matches the following format, and if so, remove everything // after the first number that isn't in brackets: // "series name #xxx - title (etc) (etc)" -> "series name #xxx (etc) (etc) - const format2 = "".match( + const format2 = inputString.match( /^((?:[a-zA-Z,.-]+\s)+)(\#?(?:\d+[.0-9*])\s*(?:-))(.*((\(.*)?))$/gis, ); }; @@ -94,7 +92,7 @@ export const tokenize = (inputString: string) => { const hyphenatedIssueRange = inputString.match(/(\d)(-\d+)/gi); if (!isNull(hyphenatedIssueRange) && hyphenatedIssueRange.length > 2) { - let issueNumber = hyphenatedIssueRange[0]; + const issueNumber = hyphenatedIssueRange[0]; } const readingListIndicators = inputString.match( diff --git a/yarn.lock b/yarn.lock index cc0e1f7..6e396a8 100644 --- a/yarn.lock +++ b/yarn.lock @@ -13154,10 +13154,10 @@ text-table@^0.2.0, text-table@~0.2.0: resolved "https://registry.yarnpkg.com/text-table/-/text-table-0.2.0.tgz#7f5ee823ae805207c00af2df4a84ec3fcfa570b4" integrity sha1-f17oI66AUgfACvLfSoTsP8+lcLQ= -threetwo-ui-typings@^1.0.1: - version "1.0.1" - resolved "https://registry.yarnpkg.com/threetwo-ui-typings/-/threetwo-ui-typings-1.0.1.tgz#5e1c4aca9342e1655ef471fe2e50752bb844b788" - integrity sha512-g5FWa069AT1WfUHHEVFOQ1q6cfK+9UOzewfKblheuDBSsGN/e89MJMEVfuInBaHgxHM32/P+mNUFBqnBoeRSLQ== +threetwo-ui-typings@^1.0.2: + version "1.0.2" + resolved "https://registry.yarnpkg.com/threetwo-ui-typings/-/threetwo-ui-typings-1.0.2.tgz#63cf3739c340d8595cb36baa8669d4d836aa2290" + integrity sha512-sK5cb/fApFKseQNgcnGmAnPNxDDXT+dQ/Blei1N4q0mduO3kZfJTnlMYaXjO4FDXLP+jkiwsv0bf7PXm0DgF7g== dependencies: typescript "^4.3.2"