diff --git a/src/client/actions/fileops.actions.tsx b/src/client/actions/fileops.actions.tsx index 82e59e5..0579b26 100644 --- a/src/client/actions/fileops.actions.tsx +++ b/src/client/actions/fileops.actions.tsx @@ -5,6 +5,9 @@ import { API_BASE_URI, SOCKET_BASE_URI } from "../constants/endpoints"; import { IMS_COMICBOOK_METADATA_FETCHED, IMS_SOCKET_CONNECTION_CONNECTED, + IMS_COMIC_BOOK_GROUPS_FETCHED, + IMS_COMIC_BOOK_GROUPS_CALL_IN_PROGRESS, + IMS_COMIC_BOOK_GROUPS_CALL_FAILED, IMS_RECENT_COMICS_FETCHED, CV_API_CALL_IN_PROGRESS, CV_SEARCH_SUCCESS, @@ -144,6 +147,30 @@ export const importToDB = (payload?: any) => (dispatch) => { }); } }; +export const fetchVolumeGroups = () => (dispatch) => { + try { + dispatch({ + type: IMS_COMIC_BOOK_GROUPS_CALL_IN_PROGRESS, + }); + axios + .request({ + url: "http://localhost:3000/api/import/getComicBookGroups", + method: "GET", + }) + .then((data) => { + console.log(data); + dispatch({ + type: IMS_COMIC_BOOK_GROUPS_FETCHED, + data, + }); + }); + } catch (error) { + dispatch({ + type: IMS_COMIC_BOOK_GROUPS_CALL_FAILED, + error, + }); + } +}; export const fetchComicVineMatches = (searchPayload) => (dispatch) => { try { const issueString = searchPayload.rawFileDetails.name; diff --git a/src/client/assets/scss/App.scss b/src/client/assets/scss/App.scss index 3a144f7..2508d7f 100644 --- a/src/client/assets/scss/App.scss +++ b/src/client/assets/scss/App.scss @@ -26,27 +26,38 @@ $border-color: red; } } -// Dashboard -.paper { - background: #fff; - width: 200px; - border-radius: 0.3rem; - box-shadow: - /* The top layer shadow */ - 0 -1px 1px rgba(0,0,0,0.15), - /* The second layer */ - 0 -10px 0 -5px #eee, - /* The second layer shadow */ - 0 -10px 1px -4px rgba(0,0,0,0.15), - /* The third layer */ - 0 -20px 0 -10px #eee, - /* The third layer shadow */ - 0 -20px 1px -9px rgba(0,0,0,0.15); - /* Padding for demo purposes */ - padding: 30px; +// Dashboard +.stack-card-container { + display: grid; + grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); + column-gap: 0.5em; + row-gap: 1.2em; + .stack { + width: 200px; + border-radius: 0.3rem; + box-shadow: + /* The top layer shadow */ 0 -1px 1px rgba(0, 0, 0, 0.15), + /* The second layer */ 0 -10px 0 -5px #eee, + /* The second layer shadow */ 0 -10px 1px -4px rgba(0, 0, 0, 0.15), + /* The third layer */ 0 -20px 0 -10px #eee, + /* The third layer shadow */ 0 -20px 1px -9px rgba(0, 0, 0, 0.15); + img { + height: auto; + border-top-left-radius: 0.3rem; + border-top-right-radius: 0.3rem; + border-bottom-left-radius: 0; + border-bottom-right-radius: 0; + } + .content { + margin: -5px 0 0 0; + padding: 0.5rem 1rem; + border-bottom-left-radius: 0.25rem; + box-shadow: 1px 8px 23px 7px rgba(0, 0, 0, 0.12); + border-bottom-right-radius: 0.25rem; + } + } } - .min { overflow: visible; margin: auto; @@ -299,7 +310,7 @@ $border-color: red; } } -// Library grid +// Library grid .my-masonry-grid { display: -webkit-box; /* Not needed if autoprefixing */ display: -ms-flexbox; /* Not needed if autoprefixing */ @@ -312,7 +323,8 @@ $border-color: red; background-clip: padding-box; } -.my-masonry-grid_column > div { /* change div to reference your elements you put in */ +.my-masonry-grid_column > div { + /* change div to reference your elements you put in */ margin-bottom: 20px; } diff --git a/src/client/components/Dashboard.tsx b/src/client/components/Dashboard.tsx index a584b02..3e94aad 100644 --- a/src/client/components/Dashboard.tsx +++ b/src/client/components/Dashboard.tsx @@ -2,6 +2,7 @@ import React, { ReactElement, useEffect } from "react"; import { useDispatch, useSelector } from "react-redux"; import ZeroState from "./ZeroState"; import { RecentlyImported } from "./RecentlyImported"; +import { VolumeGroups } from "./VolumeGroups"; import { getComicBooks } from "../actions/fileops.actions"; import { isEmpty } from "lodash"; @@ -28,11 +29,8 @@ export const Dashboard = (): ReactElement => { {!isEmpty(recentComics) && !isEmpty(recentComics.docs) ? ( <> -

Recently Imported

-
-
asdas
-
+ ) : ( ( -
- {map(comicBookCovers.docs, ({ _id, rawFileDetails, sourcedMetadata }) => { - let imagePath = ""; - let comicName = ""; - if (!isNil(rawFileDetails)) { - const encodedFilePath = encodeURI( - "http://localhost:3000" + removeLeadingPeriod(rawFileDetails.path), + <> +

Recently Imported

+
+ {map(comicBookCovers.docs, ({ _id, rawFileDetails, sourcedMetadata }) => { + let imagePath = ""; + let comicName = ""; + if (!isNil(rawFileDetails)) { + const encodedFilePath = encodeURI( + "http://localhost:3000" + removeLeadingPeriod(rawFileDetails.path), + ); + imagePath = escapePoundSymbol(encodedFilePath); + comicName = rawFileDetails.name; + } else if (!isNil(sourcedMetadata)) { + imagePath = sourcedMetadata.comicvine.image.small_url; + comicName = sourcedMetadata.comicvine.name; + } + const titleElement = ( + {ellipsize(comicName, 18)} ); - imagePath = escapePoundSymbol(encodedFilePath); - comicName = rawFileDetails.name; - } else if (!isNil(sourcedMetadata)) { - imagePath = sourcedMetadata.comicvine.image.small_url; - comicName = sourcedMetadata.comicvine.name; - } - const titleElement = ( - {ellipsize(comicName, 18)} - ); - return ( - -
- {!isNil(sourcedMetadata.comicvine) && ( - - - - )} - {isNil(rawFileDetails) && ( - - - - )} - {!isNil(sourcedMetadata.comicvine) && - !isEmpty( - detectTradePaperbacks( - sourcedMetadata.comicvine.volumeInformation.description, - ), - ) ? ( - TPB - ) : null} -
-
- ); - })} -
+ return ( + +
+ {!isNil(sourcedMetadata.comicvine) && ( + + + + )} + {isNil(rawFileDetails) && ( + + + + )} + {!isNil(sourcedMetadata.comicvine) && + !isEmpty( + detectTradePaperbacks( + sourcedMetadata.comicvine.volumeInformation.description, + ), + ) ? ( + TPB + ) : null} +
+
+ ); + })} +
+ ); diff --git a/src/client/components/VolumeGroups.tsx b/src/client/components/VolumeGroups.tsx index 03d5728..2e0c83c 100644 --- a/src/client/components/VolumeGroups.tsx +++ b/src/client/components/VolumeGroups.tsx @@ -1,7 +1,46 @@ -import React, { ReactElement } from "react"; +import { isNil, map } from "lodash"; +import React, { ReactElement, useEffect } from "react"; +import { useSelector, useDispatch } from "react-redux"; +import ellipsize from "ellipsize"; +import { fetchVolumeGroups } from "../actions/fileops.actions"; export const VolumeGroups = (): ReactElement => { - return
; + const dispatch = useDispatch(); + useEffect(() => { + dispatch(fetchVolumeGroups()); + }, [dispatch]); + const volumeGroups = useSelector( + (state: RootState) => state.fileOps.comicVolumeGroups, + ); + return ( + <> +

Volumes

+
+ {!isNil(volumeGroups) && + volumeGroups && + map(volumeGroups.data, (group) => { + if (!isNil(group)) { + return ( +
+ +
+ {ellipsize(group.results.name, 18)} +
+ + Issues + + {group.results.count_of_issues} + + +
+
+
+ ); + } + })} +
+ + ); }; export default VolumeGroups; diff --git a/src/client/constants/action-types.ts b/src/client/constants/action-types.ts index c4de391..f5241dc 100644 --- a/src/client/constants/action-types.ts +++ b/src/client/constants/action-types.ts @@ -31,6 +31,13 @@ export const IMS_COMIC_BOOK_DB_OBJECT_CALL_IN_PROGRESS = export const IMS_COMIC_BOOK_DB_OBJECT_CALL_FAILED = "IMS_COMIC_BOOK_DB_OBJECT_CALL_FAILED"; +// volume groups +export const IMS_COMIC_BOOK_GROUPS_FETCHED = "IMS_COMIC_BOOK_GROUPS_FETCHED"; +export const IMS_COMIC_BOOK_GROUPS_CALL_IN_PROGRESS = + "IMS_COMIC_BOOK_GROUPS_CALL_IN_PROGRESS"; +export const IMS_COMIC_BOOK_GROUPS_CALL_FAILED = + "IMS_COMIC_BOOK_GROUPS_CALL_FAILED"; + export const AIRDCPP_SEARCH_IN_PROGRESS = "AIRDCPP_SEARCH_IN_PROGRESS"; export const AIRDCPP_SEARCH_RESULTS_RECEIVED = "AIRDCPP_SEARCH_RESULTS_RECEIVED"; diff --git a/src/client/reducers/fileops.reducer.ts b/src/client/reducers/fileops.reducer.ts index c35ed4d..9f9a247 100644 --- a/src/client/reducers/fileops.reducer.ts +++ b/src/client/reducers/fileops.reducer.ts @@ -10,10 +10,14 @@ import { IMS_CV_METADATA_IMPORT_SUCCESSFUL, IMS_CV_METADATA_IMPORT_FAILED, IMS_CV_METADATA_IMPORT_CALL_IN_PROGRESS, + IMS_COMIC_BOOK_GROUPS_CALL_IN_PROGRESS, + IMS_COMIC_BOOK_GROUPS_FETCHED, + IMS_COMIC_BOOK_GROUPS_CALL_FAILED, } from "../constants/action-types"; const initialState = { IMSCallInProgress: false, comicBookMetadata: [], + comicVolumeGroups: [], isSocketConnected: false, isComicVineMetadataImportInProgress: false, comicVineMetadataImportError: {}, @@ -68,6 +72,26 @@ function fileOpsReducer(state = initialState, action) { isComicVineMetadataImportInProgress: false, comicVineMetadataImportError: action.importError, }; + case IMS_COMIC_BOOK_GROUPS_CALL_IN_PROGRESS: { + return { + ...state, + IMSCallInProgress: true, + }; + } + case IMS_COMIC_BOOK_GROUPS_FETCHED: { + return { + ...state, + comicVolumeGroups: action.data, + IMSCallInProgress: false, + }; + } + case IMS_COMIC_BOOK_GROUPS_CALL_FAILED: { + return { + ...state, + IMSCallInProgress: false, + error: action.error, + }; + } default: return state; }