From 2184b20887c305b924909147856cf36fd9bec569 Mon Sep 17 00:00:00 2001 From: Rishi Ghan Date: Wed, 18 Aug 2021 22:16:15 -0700 Subject: [PATCH] =?UTF-8?q?=F0=9F=94=A7=20Ability=20to=20import=20CV=20sea?= =?UTF-8?q?rch=20result=20into=20mongo?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/client/actions/fileops.actions.tsx | 18 ++-- src/client/components/Card.tsx | 2 +- src/client/components/Library.tsx | 110 ++++++++++++++------- src/client/components/RecentlyImported.tsx | 11 ++- src/client/components/Search.tsx | 3 +- 5 files changed, 92 insertions(+), 52 deletions(-) diff --git a/src/client/actions/fileops.actions.tsx b/src/client/actions/fileops.actions.tsx index b60629d..31040bc 100644 --- a/src/client/actions/fileops.actions.tsx +++ b/src/client/actions/fileops.actions.tsx @@ -112,18 +112,16 @@ export const getComicBooks = (options) => async (dispatch) => { export const importToDB = (payload) => (dispatch) => { try { - const comicBookMetadata = extend( - { - importStatus: { - isImported: true, - tagged: false, - matchedResult: { - score: "0", - }, + const comicBookMetadata = { + importStatus: { + isImported: true, + tagged: false, + matchedResult: { + score: "0", }, }, - { sourcedMetadata: { comicvine: payload } }, - ); + sourcedMetadata: { comicvine: payload }, + }; dispatch({ type: IMS_CV_METADATA_IMPORT_CALL_IN_PROGRESS, }); diff --git a/src/client/components/Card.tsx b/src/client/components/Card.tsx index cfecbc6..80f7935 100644 --- a/src/client/components/Card.tsx +++ b/src/client/components/Card.tsx @@ -38,7 +38,7 @@ class Card extends React.Component { Placeholder image - {this.props.title && ( + {this.props.hasTitle && (
    diff --git a/src/client/components/Library.tsx b/src/client/components/Library.tsx index 93f106f..9cc3ae5 100644 --- a/src/client/components/Library.tsx +++ b/src/client/components/Library.tsx @@ -36,43 +36,79 @@ export const Library = ({}: IComicBookLibraryProps): ReactElement => { }; // raw file details const RawFileDetails = ({ value }) => { - const encodedFilePath = encodeURI( - "http://localhost:3000" + removeLeadingPeriod(value.path), - ); - const filePath = escapePoundSymbol(encodedFilePath); - return ( -
    -
    -
    -
    -
    - -
    -
    -
      -
    • - {ellipsize(value.name, 18)} -
    • -
    • -
      -
      - - {value.extension} - - - {prettyBytes(value.fileSize)} - + if (!isNil(value.path)) { + const encodedFilePath = encodeURI( + "http://localhost:3000" + removeLeadingPeriod(value.path), + ); + const filePath = escapePoundSymbol(encodedFilePath); + return ( +
      +
      +
      +
      +
      + +
      +
      +
        +
      • + {ellipsize(value.name, 18)} +
      • +
      • +
        +
        + + {value.extension} + + + {prettyBytes(value.fileSize)} + +
        -
      -
    • -
    + +
+
- - ); + ); + } else if (!isNil(value.comicvine)) { + return ( +
+
+
+
+
+ +
+
+
    +
  • + {ellipsize(value.name, 18)} +
  • +
  • +
    +
    + + ComicVine ID + + + {value.comicvine.id} + +
    +
    +
  • +
+
+
+
+ ); + } }; const ImportStatus = ({ value }) => { - return `${value.toString()}` ? ( + return value ? ( Imported ) : ( "Not Imported" @@ -86,7 +122,11 @@ export const Library = ({}: IComicBookLibraryProps): ReactElement => { columns: [ { Header: "File Details", - accessor: "rawFileDetails", + id: "fileDetails", + accessor: (row) => + !isNil(row.rawFileDetails) + ? row.rawFileDetails + : row.sourcedMetadata, Cell: RawFileDetails, }, { @@ -301,7 +341,7 @@ export const Library = ({}: IComicBookLibraryProps): ReactElement => {