🙋🏽♂️ Wanted comics section on dashboard
This commit is contained in:
@@ -12,6 +12,7 @@ import {
|
|||||||
IMS_COMIC_BOOK_GROUPS_CALL_IN_PROGRESS,
|
IMS_COMIC_BOOK_GROUPS_CALL_IN_PROGRESS,
|
||||||
IMS_COMIC_BOOK_GROUPS_CALL_FAILED,
|
IMS_COMIC_BOOK_GROUPS_CALL_FAILED,
|
||||||
IMS_RECENT_COMICS_FETCHED,
|
IMS_RECENT_COMICS_FETCHED,
|
||||||
|
IMS_WANTED_COMICS_FETCHED,
|
||||||
CV_API_CALL_IN_PROGRESS,
|
CV_API_CALL_IN_PROGRESS,
|
||||||
CV_SEARCH_SUCCESS,
|
CV_SEARCH_SUCCESS,
|
||||||
CV_CLEANUP,
|
CV_CLEANUP,
|
||||||
@@ -83,21 +84,33 @@ export const fetchComicBookMetadata = (options) => async (dispatch) => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
export const getComicBooks = (options) => async (dispatch) => {
|
export const getComicBooks = (options) => async (dispatch) => {
|
||||||
const { paginationOptions } = options;
|
const { paginationOptions, predicate, comicStatus } = options;
|
||||||
return axios
|
|
||||||
.request({
|
const response = await axios.request({
|
||||||
url: `${LIBRARY_SERVICE_BASE_URI}/getComicBooks`,
|
url: `${LIBRARY_SERVICE_BASE_URI}/getComicBooks`,
|
||||||
method: "POST",
|
method: "POST",
|
||||||
data: {
|
data: {
|
||||||
paginationOptions,
|
paginationOptions,
|
||||||
},
|
predicate,
|
||||||
})
|
},
|
||||||
.then((response) => {
|
});
|
||||||
|
|
||||||
|
switch (comicStatus) {
|
||||||
|
case "recent":
|
||||||
dispatch({
|
dispatch({
|
||||||
type: IMS_RECENT_COMICS_FETCHED,
|
type: IMS_RECENT_COMICS_FETCHED,
|
||||||
data: response.data,
|
data: response.data,
|
||||||
});
|
});
|
||||||
});
|
break;
|
||||||
|
case "wanted":
|
||||||
|
dispatch({
|
||||||
|
type: IMS_WANTED_COMICS_FETCHED,
|
||||||
|
data: response.data.docs,
|
||||||
|
});
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
console.log("Unrecognized comic status.");
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
export const importToDB = (payload?: any) => (dispatch) => {
|
export const importToDB = (payload?: any) => (dispatch) => {
|
||||||
@@ -111,6 +124,7 @@ export const importToDB = (payload?: any) => (dispatch) => {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
sourcedMetadata: { comicvine: payload || null },
|
sourcedMetadata: { comicvine: payload || null },
|
||||||
|
acquisition: { wanted: true },
|
||||||
};
|
};
|
||||||
dispatch({
|
dispatch({
|
||||||
type: IMS_CV_METADATA_IMPORT_CALL_IN_PROGRESS,
|
type: IMS_CV_METADATA_IMPORT_CALL_IN_PROGRESS,
|
||||||
@@ -136,37 +150,30 @@ export const importToDB = (payload?: any) => (dispatch) => {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
export const fetchVolumeGroups = () => (dispatch) => {
|
export const fetchVolumeGroups = () => async (dispatch) => {
|
||||||
try {
|
try {
|
||||||
dispatch({
|
dispatch({
|
||||||
type: IMS_COMIC_BOOK_GROUPS_CALL_IN_PROGRESS,
|
type: IMS_COMIC_BOOK_GROUPS_CALL_IN_PROGRESS,
|
||||||
});
|
});
|
||||||
axios
|
const response = await axios.request({
|
||||||
.request({
|
url: `${LIBRARY_SERVICE_BASE_URI}/getComicBookGroups`,
|
||||||
url: `${LIBRARY_SERVICE_BASE_URI}/getComicBookGroups`,
|
method: "GET",
|
||||||
method: "GET",
|
|
||||||
})
|
|
||||||
.then((data) => {
|
|
||||||
dispatch({
|
|
||||||
type: IMS_COMIC_BOOK_GROUPS_FETCHED,
|
|
||||||
data: data.data,
|
|
||||||
});
|
|
||||||
});
|
|
||||||
} catch (error) {
|
|
||||||
dispatch({
|
|
||||||
type: IMS_COMIC_BOOK_GROUPS_CALL_FAILED,
|
|
||||||
error,
|
|
||||||
});
|
});
|
||||||
|
|
||||||
|
dispatch({
|
||||||
|
type: IMS_COMIC_BOOK_GROUPS_FETCHED,
|
||||||
|
data: response.data,
|
||||||
|
});
|
||||||
|
} catch (error) {
|
||||||
|
console.log(error);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
export const fetchComicVineMatches =
|
export const fetchComicVineMatches =
|
||||||
(searchPayload, issueSearchQuery, seriesSearchQuery?) => (dispatch) => {
|
(searchPayload, issueSearchQuery, seriesSearchQuery?) => async (dispatch) => {
|
||||||
try {
|
try {
|
||||||
dispatch({
|
dispatch({
|
||||||
type: CV_API_CALL_IN_PROGRESS,
|
type: CV_API_CALL_IN_PROGRESS,
|
||||||
});
|
});
|
||||||
console.log(issueSearchQuery);
|
|
||||||
console.log(seriesSearchQuery);
|
|
||||||
axios
|
axios
|
||||||
.request({
|
.request({
|
||||||
url: `${COMICVINE_SERVICE_URI}/volumeBasedSearch`,
|
url: `${COMICVINE_SERVICE_URI}/volumeBasedSearch`,
|
||||||
|
|||||||
@@ -4,7 +4,6 @@ import { useParams } from "react-router-dom";
|
|||||||
import Card from "./Carda";
|
import Card from "./Carda";
|
||||||
import { ComicVineMatchPanel } from "./ComicDetail/ComicVineMatchPanel";
|
import { ComicVineMatchPanel } from "./ComicDetail/ComicVineMatchPanel";
|
||||||
import { VolumeInformation } from "./ComicDetail/Tabs/VolumeInformation";
|
import { VolumeInformation } from "./ComicDetail/Tabs/VolumeInformation";
|
||||||
import { ComicVineDetails } from "./ComicDetail/ComicVineDetails";
|
|
||||||
import { RawFileDetails } from "./ComicDetail/RawFileDetails";
|
import { RawFileDetails } from "./ComicDetail/RawFileDetails";
|
||||||
import { ArchiveOperations } from "./ComicDetail/Tabs/ArchiveOperations";
|
import { ArchiveOperations } from "./ComicDetail/Tabs/ArchiveOperations";
|
||||||
import AcquisitionPanel from "./ComicDetail/AcquisitionPanel";
|
import AcquisitionPanel from "./ComicDetail/AcquisitionPanel";
|
||||||
|
|||||||
@@ -2,16 +2,21 @@ import React, { ReactElement, useEffect } from "react";
|
|||||||
import { useDispatch, useSelector } from "react-redux";
|
import { useDispatch, useSelector } from "react-redux";
|
||||||
import ZeroState from "./ZeroState";
|
import ZeroState from "./ZeroState";
|
||||||
import { RecentlyImported } from "./RecentlyImported";
|
import { RecentlyImported } from "./RecentlyImported";
|
||||||
|
import { WantedComicsList } from "./WantedComicsList";
|
||||||
import { VolumeGroups } from "./VolumeGroups";
|
import { VolumeGroups } from "./VolumeGroups";
|
||||||
import { PullList } from "./PullList";
|
import { PullList } from "./PullList";
|
||||||
import { getComicBooks } from "../../actions/fileops.actions";
|
import {
|
||||||
|
fetchVolumeGroups,
|
||||||
|
getComicBooks,
|
||||||
|
} from "../../actions/fileops.actions";
|
||||||
import { getLibraryStatistics } from "../../actions/comicinfo.actions";
|
import { getLibraryStatistics } from "../../actions/comicinfo.actions";
|
||||||
import { isEmpty, isNil, isUndefined, map } from "lodash";
|
import { isEmpty, isUndefined, map } from "lodash";
|
||||||
import prettyBytes from "pretty-bytes";
|
import prettyBytes from "pretty-bytes";
|
||||||
|
|
||||||
export const Dashboard = (): ReactElement => {
|
export const Dashboard = (): ReactElement => {
|
||||||
const dispatch = useDispatch();
|
const dispatch = useDispatch();
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
|
dispatch(fetchVolumeGroups());
|
||||||
dispatch(
|
dispatch(
|
||||||
getComicBooks({
|
getComicBooks({
|
||||||
paginationOptions: {
|
paginationOptions: {
|
||||||
@@ -19,13 +24,30 @@ export const Dashboard = (): ReactElement => {
|
|||||||
limit: 5,
|
limit: 5,
|
||||||
sort: { updatedAt: "-1" },
|
sort: { updatedAt: "-1" },
|
||||||
},
|
},
|
||||||
|
predicate: { "acquisition.wanted": false },
|
||||||
|
comicStatus: "recent",
|
||||||
|
}),
|
||||||
|
);
|
||||||
|
dispatch(
|
||||||
|
getComicBooks({
|
||||||
|
paginationOptions: {
|
||||||
|
page: 0,
|
||||||
|
limit: 5,
|
||||||
|
sort: { updatedAt: "-1" },
|
||||||
|
},
|
||||||
|
predicate: { "acquisition.wanted": true },
|
||||||
|
comicStatus: "wanted",
|
||||||
}),
|
}),
|
||||||
);
|
);
|
||||||
dispatch(getLibraryStatistics());
|
dispatch(getLibraryStatistics());
|
||||||
}, [dispatch]);
|
}, []);
|
||||||
|
|
||||||
const recentComics = useSelector(
|
const recentComics = useSelector(
|
||||||
(state: RootState) => state.fileOps.recentComics,
|
(state: RootState) => state.fileOps.recentComics,
|
||||||
);
|
);
|
||||||
|
const wantedComics = useSelector(
|
||||||
|
(state: RootState) => state.fileOps.wantedComics,
|
||||||
|
);
|
||||||
const volumeGroups = useSelector(
|
const volumeGroups = useSelector(
|
||||||
(state: RootState) => state.fileOps.comicVolumeGroups,
|
(state: RootState) => state.fileOps.comicVolumeGroups,
|
||||||
);
|
);
|
||||||
@@ -153,8 +175,9 @@ export const Dashboard = (): ReactElement => {
|
|||||||
</dl>
|
</dl>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
<WantedComicsList comics={wantedComics} />
|
||||||
<RecentlyImported comicBookCovers={recentComics} />
|
<RecentlyImported comicBookCovers={recentComics} />
|
||||||
{!isNil(volumeGroups) ? <VolumeGroups /> : null}
|
<VolumeGroups volumeGroups={volumeGroups} />
|
||||||
</>
|
</>
|
||||||
) : (
|
) : (
|
||||||
<ZeroState
|
<ZeroState
|
||||||
|
|||||||
@@ -1,25 +1,16 @@
|
|||||||
import { isNil, map } from "lodash";
|
import { map } from "lodash";
|
||||||
import React, { ReactElement, useEffect } from "react";
|
import React, { ReactElement } from "react";
|
||||||
import { useSelector, useDispatch } from "react-redux";
|
|
||||||
import ellipsize from "ellipsize";
|
import ellipsize from "ellipsize";
|
||||||
import { Link } from "react-router-dom";
|
import { Link } from "react-router-dom";
|
||||||
import { fetchVolumeGroups } from "../../actions/fileops.actions";
|
|
||||||
import Masonry from "react-masonry-css";
|
import Masonry from "react-masonry-css";
|
||||||
|
|
||||||
export const VolumeGroups = (): ReactElement => {
|
export const VolumeGroups = (props): ReactElement => {
|
||||||
const breakpointColumnsObj = {
|
const breakpointColumnsObj = {
|
||||||
default: 5,
|
default: 5,
|
||||||
1100: 4,
|
1100: 4,
|
||||||
700: 2,
|
700: 2,
|
||||||
500: 1,
|
500: 1,
|
||||||
};
|
};
|
||||||
const dispatch = useDispatch();
|
|
||||||
useEffect(() => {
|
|
||||||
dispatch(fetchVolumeGroups());
|
|
||||||
}, [dispatch]);
|
|
||||||
const volumeGroups = useSelector(
|
|
||||||
(state: RootState) => state.fileOps.comicVolumeGroups,
|
|
||||||
);
|
|
||||||
return (
|
return (
|
||||||
<section className="volumes-container mt-4">
|
<section className="volumes-container mt-4">
|
||||||
<div className="content">
|
<div className="content">
|
||||||
@@ -31,32 +22,30 @@ export const VolumeGroups = (): ReactElement => {
|
|||||||
className="volumes-grid"
|
className="volumes-grid"
|
||||||
columnClassName="volumes-grid-column"
|
columnClassName="volumes-grid-column"
|
||||||
>
|
>
|
||||||
{!isNil(volumeGroups) &&
|
{map(props.volumeGroups, (data) => {
|
||||||
volumeGroups &&
|
return map(data.data, (group) => {
|
||||||
map(volumeGroups, (group) => {
|
return (
|
||||||
if (!isNil(group._id)) {
|
<div className="stack" key={group.id}>
|
||||||
return (
|
<img src={group.volume.image.small_url} />
|
||||||
<div className="stack" key={group._id.id}>
|
<div className="content">
|
||||||
<img src={group.data[0].image.small_url} />
|
<div className="stack-title is-size-8">
|
||||||
<div className="content">
|
<Link to={`/volume/details/${group.id}`}>
|
||||||
<div className="stack-title is-size-8">
|
{ellipsize(group.volume.name, 18)}
|
||||||
<Link to={`/volume/details/${group.comicBookObjectId}`}>
|
</Link>
|
||||||
{ellipsize(group.data[0].name, 18)}
|
</div>
|
||||||
</Link>
|
<div className="control">
|
||||||
</div>
|
<span className="tags has-addons">
|
||||||
<div className="control">
|
<span className="tag is-primary is-light">Issues</span>
|
||||||
<span className="tags has-addons">
|
<span className="tag">
|
||||||
<span className="tag is-primary is-light">Issues</span>
|
{group.volume.count_of_issues}
|
||||||
<span className="tag">
|
|
||||||
{group.data[0].count_of_issues}
|
|
||||||
</span>
|
|
||||||
</span>
|
</span>
|
||||||
</div>
|
</span>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
);
|
</div>
|
||||||
}
|
);
|
||||||
})}
|
});
|
||||||
|
})}
|
||||||
</Masonry>
|
</Masonry>
|
||||||
</section>
|
</section>
|
||||||
);
|
);
|
||||||
|
|||||||
93
src/client/components/Dashboard/WantedComicsList.tsx
Normal file
93
src/client/components/Dashboard/WantedComicsList.tsx
Normal file
@@ -0,0 +1,93 @@
|
|||||||
|
import React, { ReactElement } from "react";
|
||||||
|
import Card from "../Carda";
|
||||||
|
import { Link } from "react-router-dom";
|
||||||
|
import ellipsize from "ellipsize";
|
||||||
|
import { isEmpty, isNil, isUndefined, map } from "lodash";
|
||||||
|
import { detectIssueTypes } from "../../shared/utils/tradepaperback.utils";
|
||||||
|
import Masonry from "react-masonry-css";
|
||||||
|
|
||||||
|
type WantedComicsListProps = {
|
||||||
|
comics: any;
|
||||||
|
};
|
||||||
|
|
||||||
|
export const WantedComicsList = ({
|
||||||
|
comics,
|
||||||
|
}: WantedComicsListProps): ReactElement => {
|
||||||
|
const breakpointColumnsObj = {
|
||||||
|
default: 5,
|
||||||
|
1100: 4,
|
||||||
|
700: 2,
|
||||||
|
600: 2,
|
||||||
|
};
|
||||||
|
|
||||||
|
return (
|
||||||
|
<>
|
||||||
|
<div className="content">
|
||||||
|
<h4 className="title is-4">Wanted Comics</h4>
|
||||||
|
<p className="subtitle is-7">
|
||||||
|
Comics marked as wanted from various sources.
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
<Masonry
|
||||||
|
breakpointCols={breakpointColumnsObj}
|
||||||
|
className="recent-comics-container"
|
||||||
|
columnClassName="recent-comics-column"
|
||||||
|
>
|
||||||
|
{map(comics, ({ _id, rawFileDetails, sourcedMetadata }) => {
|
||||||
|
const isComicBookMetadataAvailable =
|
||||||
|
sourcedMetadata &&
|
||||||
|
!isUndefined(sourcedMetadata.comicvine) &&
|
||||||
|
!isUndefined(sourcedMetadata.comicvine.volumeInformation) &&
|
||||||
|
!isEmpty(sourcedMetadata);
|
||||||
|
let imagePath = "";
|
||||||
|
let comicName = "";
|
||||||
|
if (isComicBookMetadataAvailable) {
|
||||||
|
imagePath = sourcedMetadata.comicvine.image.small_url;
|
||||||
|
comicName = sourcedMetadata.comicvine.name;
|
||||||
|
}
|
||||||
|
const titleElement = (
|
||||||
|
<Link to={"/comic/details/" + _id}>{ellipsize(comicName, 20)}</Link>
|
||||||
|
);
|
||||||
|
return (
|
||||||
|
<Card
|
||||||
|
key={_id}
|
||||||
|
orientation={"vertical"}
|
||||||
|
imageUrl={imagePath}
|
||||||
|
hasDetails
|
||||||
|
title={comicName ? titleElement : <span>No Name</span>}
|
||||||
|
>
|
||||||
|
<div className="content is-flex is-flex-direction-row">
|
||||||
|
{isComicBookMetadataAvailable && (
|
||||||
|
<span className="icon custom-icon is-small">
|
||||||
|
<img src="/img/cvlogo.svg" />
|
||||||
|
</span>
|
||||||
|
)}
|
||||||
|
{/* Raw file presence */}
|
||||||
|
{isEmpty(rawFileDetails.cover) && (
|
||||||
|
<span className="icon custom-icon is-small has-text-danger mr-2">
|
||||||
|
<img src="/img/missing-file.svg" />
|
||||||
|
</span>
|
||||||
|
)}
|
||||||
|
{/* Issue type */}
|
||||||
|
{isComicBookMetadataAvailable &&
|
||||||
|
!isNil(
|
||||||
|
detectIssueTypes(
|
||||||
|
sourcedMetadata.comicvine.volumeInformation.description,
|
||||||
|
),
|
||||||
|
) ? (
|
||||||
|
<span className="tag is-warning">
|
||||||
|
{
|
||||||
|
detectIssueTypes(
|
||||||
|
sourcedMetadata.comicvine.volumeInformation.description,
|
||||||
|
).displayName
|
||||||
|
}
|
||||||
|
</span>
|
||||||
|
) : null}
|
||||||
|
</div>
|
||||||
|
</Card>
|
||||||
|
);
|
||||||
|
})}
|
||||||
|
</Masonry>
|
||||||
|
</>
|
||||||
|
);
|
||||||
|
};
|
||||||
@@ -41,6 +41,9 @@ export const IMS_COMIC_BOOK_DB_OBJECT_CALL_IN_PROGRESS =
|
|||||||
export const IMS_COMIC_BOOK_DB_OBJECT_CALL_FAILED =
|
export const IMS_COMIC_BOOK_DB_OBJECT_CALL_FAILED =
|
||||||
"IMS_COMIC_BOOK_DB_OBJECT_CALL_FAILED";
|
"IMS_COMIC_BOOK_DB_OBJECT_CALL_FAILED";
|
||||||
|
|
||||||
|
// wanted comics from CV, LoCG and other sources
|
||||||
|
export const IMS_WANTED_COMICS_FETCHED = "IMS_WANTED_COMICS_FETCHED";
|
||||||
|
|
||||||
// volume groups
|
// volume groups
|
||||||
export const IMS_COMIC_BOOK_GROUPS_FETCHED = "IMS_COMIC_BOOK_GROUPS_FETCHED";
|
export const IMS_COMIC_BOOK_GROUPS_FETCHED = "IMS_COMIC_BOOK_GROUPS_FETCHED";
|
||||||
export const IMS_COMIC_BOOK_GROUPS_CALL_IN_PROGRESS =
|
export const IMS_COMIC_BOOK_GROUPS_CALL_IN_PROGRESS =
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ import {
|
|||||||
IMS_RAW_IMPORT_SUCCESSFUL,
|
IMS_RAW_IMPORT_SUCCESSFUL,
|
||||||
IMS_RAW_IMPORT_FAILED,
|
IMS_RAW_IMPORT_FAILED,
|
||||||
IMS_RECENT_COMICS_FETCHED,
|
IMS_RECENT_COMICS_FETCHED,
|
||||||
|
IMS_WANTED_COMICS_FETCHED,
|
||||||
IMS_CV_METADATA_IMPORT_SUCCESSFUL,
|
IMS_CV_METADATA_IMPORT_SUCCESSFUL,
|
||||||
IMS_CV_METADATA_IMPORT_FAILED,
|
IMS_CV_METADATA_IMPORT_FAILED,
|
||||||
IMS_CV_METADATA_IMPORT_CALL_IN_PROGRESS,
|
IMS_CV_METADATA_IMPORT_CALL_IN_PROGRESS,
|
||||||
@@ -32,6 +33,8 @@ const initialState = {
|
|||||||
comicVineMetadataImportError: {},
|
comicVineMetadataImportError: {},
|
||||||
rawImportError: {},
|
rawImportError: {},
|
||||||
extractedComicBookArchive: [],
|
extractedComicBookArchive: [],
|
||||||
|
recentComics: [],
|
||||||
|
wantedComics: [],
|
||||||
};
|
};
|
||||||
|
|
||||||
function fileOpsReducer(state = initialState, action) {
|
function fileOpsReducer(state = initialState, action) {
|
||||||
@@ -65,6 +68,12 @@ function fileOpsReducer(state = initialState, action) {
|
|||||||
...state,
|
...state,
|
||||||
recentComics: action.data,
|
recentComics: action.data,
|
||||||
};
|
};
|
||||||
|
case IMS_WANTED_COMICS_FETCHED:
|
||||||
|
console.log(action.data);
|
||||||
|
return {
|
||||||
|
...state,
|
||||||
|
wantedComics: action.data,
|
||||||
|
};
|
||||||
case IMS_CV_METADATA_IMPORT_SUCCESSFUL:
|
case IMS_CV_METADATA_IMPORT_SUCCESSFUL:
|
||||||
return {
|
return {
|
||||||
...state,
|
...state,
|
||||||
|
|||||||
Reference in New Issue
Block a user