🏗️ Added stats to dashboard
This commit is contained in:
@@ -5,7 +5,6 @@ import { WantedComicsList } from "./WantedComicsList";
|
|||||||
import { VolumeGroups } from "./VolumeGroups";
|
import { VolumeGroups } from "./VolumeGroups";
|
||||||
import { LibraryStatistics } from "./LibraryStatistics";
|
import { LibraryStatistics } from "./LibraryStatistics";
|
||||||
import { PullList } from "./PullList";
|
import { PullList } from "./PullList";
|
||||||
import { getLibraryStatistics } from "../../actions/comicinfo.actions";
|
|
||||||
import { useQuery } from "@tanstack/react-query";
|
import { useQuery } from "@tanstack/react-query";
|
||||||
import axios from "axios";
|
import axios from "axios";
|
||||||
import { LIBRARY_SERVICE_BASE_URI } from "../../constants/endpoints";
|
import { LIBRARY_SERVICE_BASE_URI } from "../../constants/endpoints";
|
||||||
@@ -54,16 +53,23 @@ export const Dashboard = (): ReactElement => {
|
|||||||
queryKey: ["volumeGroups"],
|
queryKey: ["volumeGroups"],
|
||||||
});
|
});
|
||||||
|
|
||||||
//
|
const { data: statistics } = useQuery({
|
||||||
// const libraryStatistics = useSelector(
|
queryFn: async () =>
|
||||||
// (state: RootState) => state.comicInfo.libraryStatistics,
|
await axios({
|
||||||
// );
|
url: `${LIBRARY_SERVICE_BASE_URI}/libraryStatistics`,
|
||||||
|
method: "GET",
|
||||||
|
}),
|
||||||
|
queryKey: ["libraryStatistics"],
|
||||||
|
});
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="container mx-auto max-w-full">
|
<div className="container mx-auto max-w-full">
|
||||||
<PullList />
|
<PullList />
|
||||||
{recentComics && <RecentlyImported comics={recentComics?.data.docs} />}
|
{recentComics && <RecentlyImported comics={recentComics?.data.docs} />}
|
||||||
{/* Wanted comics */}
|
{/* Wanted comics */}
|
||||||
<WantedComicsList comics={wantedComics?.data?.docs} />
|
<WantedComicsList comics={wantedComics?.data?.docs} />
|
||||||
|
{/* Library Statistics */}
|
||||||
|
{statistics && <LibraryStatistics stats={statistics?.data} />}
|
||||||
{/* Volume groups */}
|
{/* Volume groups */}
|
||||||
<VolumeGroups volumeGroups={volumeGroups?.data} />
|
<VolumeGroups volumeGroups={volumeGroups?.data} />
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -1,113 +1,99 @@
|
|||||||
import React, { ReactElement, useEffect } from "react";
|
import React, { ReactElement, useEffect } from "react";
|
||||||
import prettyBytes from "pretty-bytes";
|
import prettyBytes from "pretty-bytes";
|
||||||
import { isEmpty, isUndefined, map } from "lodash";
|
import { isEmpty, isUndefined, map } from "lodash";
|
||||||
|
import Header from "../shared/Header";
|
||||||
|
|
||||||
export const LibraryStatistics = (
|
export const LibraryStatistics = (
|
||||||
props: ILibraryStatisticsProps,
|
props: ILibraryStatisticsProps,
|
||||||
): ReactElement => {
|
): ReactElement => {
|
||||||
// const { stats } = props;
|
const { stats } = props;
|
||||||
return (
|
return (
|
||||||
<div className="mt-5">
|
<div className="mt-5">
|
||||||
<h4 className="title is-4">
|
<Header
|
||||||
<i className="fa-solid fa-chart-simple"></i> Your Library In Numbers
|
headerContent="Your Library In Numbers"
|
||||||
</h4>
|
subHeaderContent={
|
||||||
<p className="subtitle is-7">A brief snapshot of your library.</p>
|
<span className="text-md">A brief snapshot of your library.</span>
|
||||||
<div className="columns is-multiline">
|
}
|
||||||
<div className="column is-narrow is-two-quarter">
|
iconClassNames="fa-solid fa-binoculars mr-2"
|
||||||
<dl className="box">
|
/>
|
||||||
<dd className="is-size-4">
|
|
||||||
<span className="has-text-weight-bold">
|
<div className="mt-3">
|
||||||
{props.stats.totalDocuments}
|
<div className="flex flex-row gap-5">
|
||||||
</span>{" "}
|
<div className="flex flex-col rounded-lg bg-green-100 dark:bg-green-200 px-4 py-6 text-center">
|
||||||
files
|
<dt className="text-lg font-medium text-gray-500">Library size</dt>
|
||||||
|
<dd className="text-3xl text-green-600 md:text-5xl">
|
||||||
|
{props.stats.totalDocuments} files
|
||||||
</dd>
|
</dd>
|
||||||
<dd className="is-size-4">
|
<dd>
|
||||||
Library size
|
<span className="text-2xl text-green-600">
|
||||||
<span className="has-text-weight-bold">
|
|
||||||
{" "}
|
|
||||||
{props.stats.comicDirectorySize &&
|
{props.stats.comicDirectorySize &&
|
||||||
prettyBytes(props.stats.comicDirectorySize)}
|
prettyBytes(props.stats.comicDirectorySize)}
|
||||||
</span>
|
</span>
|
||||||
</dd>
|
</dd>
|
||||||
|
</div>
|
||||||
|
{/* comicinfo and comicvine tagged issues */}
|
||||||
|
<div className="flex flex-col gap-4">
|
||||||
{!isUndefined(props.stats.statistics) &&
|
{!isUndefined(props.stats.statistics) &&
|
||||||
!isEmpty(props.stats.statistics[0].issues) && (
|
!isEmpty(props.stats.statistics[0].issues) && (
|
||||||
<dd className="is-size-6">
|
<div className="flex flex-col h-fit rounded-lg bg-green-100 dark:bg-green-200 px-4 py-3 text-center">
|
||||||
<span className="has-text-weight-bold">
|
<span className="text-xl">
|
||||||
{props.stats.statistics[0].issues.length}
|
{props.stats.statistics[0].issues.length}
|
||||||
</span>{" "}
|
</span>{" "}
|
||||||
tagged with ComicVine
|
tagged with ComicVine
|
||||||
</dd>
|
</div>
|
||||||
)}
|
)}
|
||||||
{!isUndefined(props.stats.statistics) &&
|
{!isUndefined(props.stats.statistics) &&
|
||||||
!isEmpty(props.stats.statistics[0].issuesWithComicInfoXML) && (
|
!isEmpty(props.stats.statistics[0].issuesWithComicInfoXML) && (
|
||||||
<dd className="is-size-6">
|
<div className="flex flex-col h-fit rounded-lg bg-green-100 dark:bg-green-200 px-4 py-3 text-center">
|
||||||
<span className="has-text-weight-bold">
|
<span className="text-xl">
|
||||||
{props.stats.statistics[0].issuesWithComicInfoXML.length}
|
{props.stats.statistics[0].issuesWithComicInfoXML.length}
|
||||||
</span>{" "}
|
</span>{" "}
|
||||||
with
|
|
||||||
<span className="tag is-warning has-text-weight-bold mr-2 ml-1">
|
<span className="tag is-warning has-text-weight-bold mr-2 ml-1">
|
||||||
ComicInfo.xml
|
with ComicInfo.xml
|
||||||
</span>
|
</span>
|
||||||
</dd>
|
</div>
|
||||||
)}
|
)}
|
||||||
</dl>
|
</div>
|
||||||
</div>
|
|
||||||
|
|
||||||
<div className="p-3 column is-one-quarter">
|
<div className="">
|
||||||
<dl className="box">
|
{!isUndefined(props.stats.statistics) &&
|
||||||
<dd className="is-size-6">
|
!isEmpty(props.stats.statistics[0].fileTypes) &&
|
||||||
<span className="has-text-weight-bold"></span> Issues
|
map(props.stats.statistics[0].fileTypes, (fileType, idx) => {
|
||||||
</dd>
|
return (
|
||||||
<dd className="is-size-6">
|
<span
|
||||||
<span className="has-text-weight-bold">304</span> Volumes
|
key={idx}
|
||||||
</dd>
|
className="flex flex-col mb-4 h-fit text-xl rounded-lg bg-green-100 dark:bg-green-200 px-4 py-3 text-center"
|
||||||
<dd className="is-size-6">
|
>
|
||||||
{!isUndefined(props.stats.statistics) &&
|
{fileType.data.length} {fileType._id}
|
||||||
!isEmpty(props.stats.statistics[0].fileTypes) &&
|
</span>
|
||||||
map(props.stats.statistics[0].fileTypes, (fileType, idx) => {
|
);
|
||||||
return (
|
})}
|
||||||
<span key={idx}>
|
</div>
|
||||||
<span className="has-text-weight-bold">
|
|
||||||
{fileType.data.length}
|
|
||||||
</span>
|
|
||||||
<span className="tag is-warning has-text-weight-bold mr-2 ml-1">
|
|
||||||
{fileType._id}
|
|
||||||
</span>
|
|
||||||
</span>
|
|
||||||
);
|
|
||||||
})}
|
|
||||||
</dd>
|
|
||||||
</dl>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
{/* file types */}
|
{/* file types */}
|
||||||
<div className="p-3 column is-two-fifths">
|
<div className="flex flex-col h-fit text-lg rounded-lg bg-green-100 dark:bg-green-200 px-4 py-3">
|
||||||
{/* publisher with most issues */}
|
{/* publisher with most issues */}
|
||||||
<dl className="box">
|
|
||||||
{!isUndefined(props.stats.statistics) &&
|
{!isUndefined(props.stats.statistics) &&
|
||||||
!isEmpty(
|
!isEmpty(
|
||||||
props.stats.statistics[0].publisherWithMostComicsInLibrary[0],
|
props.stats.statistics[0].publisherWithMostComicsInLibrary[0],
|
||||||
) && (
|
) && (
|
||||||
<dd className="is-size-6">
|
<>
|
||||||
<span className="has-text-weight-bold">
|
<span className="">
|
||||||
{
|
{
|
||||||
props.stats.statistics[0]
|
props.stats.statistics[0]
|
||||||
.publisherWithMostComicsInLibrary[0]._id
|
.publisherWithMostComicsInLibrary[0]._id
|
||||||
}
|
}
|
||||||
</span>
|
</span>
|
||||||
{" has the most issues "}
|
{" has the most issues "}
|
||||||
<span className="has-text-weight-bold">
|
<span className="">
|
||||||
{
|
{
|
||||||
props.stats.statistics[0]
|
props.stats.statistics[0]
|
||||||
.publisherWithMostComicsInLibrary[0].count
|
.publisherWithMostComicsInLibrary[0].count
|
||||||
}
|
}
|
||||||
</span>
|
</span>
|
||||||
</dd>
|
</>
|
||||||
)}
|
)}
|
||||||
<dd className="is-size-6">
|
</div>
|
||||||
<span className="has-text-weight-bold">304</span> Volumes
|
|
||||||
</dd>
|
|
||||||
</dl>
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -82,7 +82,17 @@ export const PullList = (): ReactElement => {
|
|||||||
<div className="content">
|
<div className="content">
|
||||||
<Header
|
<Header
|
||||||
headerContent="Discover"
|
headerContent="Discover"
|
||||||
subHeaderContent="Pull List aggregated for the week from League Of Comic Geeks"
|
subHeaderContent={
|
||||||
|
<span className="text-md">
|
||||||
|
Pull List aggregated for the week from{" "}
|
||||||
|
<span className="underline">
|
||||||
|
<a href="https://leagueofcomicgeeks.com/comics/new-comics">
|
||||||
|
League Of Comic Geeks
|
||||||
|
</a>
|
||||||
|
<i className="icon-[solar--arrow-right-up-outline] w-4 h-4" />
|
||||||
|
</span>
|
||||||
|
</span>
|
||||||
|
}
|
||||||
iconClassNames="fa-solid fa-binoculars mr-2"
|
iconClassNames="fa-solid fa-binoculars mr-2"
|
||||||
link="/pull-list/all/"
|
link="/pull-list/all/"
|
||||||
/>
|
/>
|
||||||
@@ -101,7 +111,10 @@ export const PullList = (): ReactElement => {
|
|||||||
/>
|
/>
|
||||||
{inputValue && (
|
{inputValue && (
|
||||||
<div className="text-sm">
|
<div className="text-sm">
|
||||||
Showing pull list for <span>{inputValue}</span>
|
Showing pull list for{" "}
|
||||||
|
<span className="inline-flex mb-2 items-center bg-slate-50 text-slate-800 text-xs font-medium px-2.5 py-1 rounded-md dark:text-slate-900 dark:bg-slate-400">
|
||||||
|
{inputValue}
|
||||||
|
</span>
|
||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ import { Link } from "react-router-dom";
|
|||||||
|
|
||||||
type IHeaderProps = {
|
type IHeaderProps = {
|
||||||
headerContent: string;
|
headerContent: string;
|
||||||
subHeaderContent: string;
|
subHeaderContent: ReactElement;
|
||||||
iconClassNames: string;
|
iconClassNames: string;
|
||||||
link?: string;
|
link?: string;
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user