diff --git a/src/components/card/card.jsx b/src/components/card/card.jsx index e7c2f9c..f8c11ac 100644 --- a/src/components/card/card.jsx +++ b/src/components/card/card.jsx @@ -9,6 +9,7 @@ import CardMedia from "@mui/material/CardMedia"; import CardActionArea from "@mui/material/CardActionArea"; import Typography from "@mui/material/Typography"; import LinearProgress from "@mui/material/LinearProgress"; +import Chip from "@mui/material/Chip"; import { MediaCollectionTypeIconCollectionCard, @@ -17,6 +18,7 @@ import { import { borderRadiusDefault } from "../../palette.module.scss"; import "./card.module.scss"; +import { MdiCheck } from "../icons/mdiCheck"; export const Card = ({ itemName, @@ -29,6 +31,8 @@ export const Card = ({ cardOrientation, props, onClickEvent, + watchedStatus, + watchedCount, }) => { return ( + {watchedStatus && ( + } + /> + )} + {!!watchedCount && ( + + )} {imageTags && (cardType == "thumb" ? ( @@ -176,4 +194,6 @@ Card.propTypes = { playedPercent: PropTypes.number, cardOrientation: PropTypes.string.isRequired, onClickEvent: PropTypes.func, + watchedStatus: PropTypes.bool, + watchedCount: PropTypes.number, }; diff --git a/src/components/card/card.module.scss b/src/components/card/card.module.scss index 0a2bcc0..3948065 100644 --- a/src/components/card/card.module.scss +++ b/src/components/card/card.module.scss @@ -37,4 +37,18 @@ justify-content: center; align-items: center; } + &-indicator { + position: absolute; + right: 5px; + top: 5px; + // padding: 2px 10px; + z-index: 10; + // border-radius: 100px; + background: $clr-gradient-default; + box-shadow: 0 0 5px rgb(0 0 0 / 0.4); + &-text { + aspect-ratio: 1; + padding: 5px !important; + } + } } diff --git a/src/components/icons/mdiCheck.jsx b/src/components/icons/mdiCheck.jsx new file mode 100644 index 0000000..abb17ac --- /dev/null +++ b/src/components/icons/mdiCheck.jsx @@ -0,0 +1,13 @@ +/** @format */ + +import SvgIcon from "@mui/material/SvgIcon"; + +import { mdiCheck } from "@mdi/js"; + +export const MdiCheck = (props) => { + return ( + + + + ); +}; diff --git a/src/components/icons/mdiSortAscending.jsx b/src/components/icons/mdiSortAscending.jsx new file mode 100644 index 0000000..429a004 --- /dev/null +++ b/src/components/icons/mdiSortAscending.jsx @@ -0,0 +1,12 @@ +/** @format */ +import SvgIcon from "@mui/material/SvgIcon"; + +import { mdiSortAscending } from "@mdi/js"; + +export const MdiSortAscending = (props) => { + return ( + + + + ); +}; diff --git a/src/components/icons/mdiSortDescending.jsx b/src/components/icons/mdiSortDescending.jsx new file mode 100644 index 0000000..9e11bfe --- /dev/null +++ b/src/components/icons/mdiSortDescending.jsx @@ -0,0 +1,12 @@ +/** @format */ +import SvgIcon from "@mui/material/SvgIcon"; + +import { mdiSortDescending } from "@mdi/js"; + +export const MdiSortDescending = (props) => { + return ( + + + + ); +}; diff --git a/src/routes/library/root.jsx b/src/routes/library/root.jsx index 116b3d5..d876397 100644 --- a/src/routes/library/root.jsx +++ b/src/routes/library/root.jsx @@ -12,16 +12,16 @@ import { useQuery } from "@tanstack/react-query"; import Box from "@mui/material/Box"; import Grid2 from "@mui/material/Unstable_Grid2"; -import useScrollTrigger from "@mui/material/useScrollTrigger"; +import Stack from "@mui/material/Stack"; import AppBar from "@mui/material/AppBar"; import Toolbar from "@mui/material/Toolbar"; import Typography from "@mui/material/Typography"; import CircularProgress from "@mui/material/CircularProgress"; import Divider from "@mui/material/Divider"; import Chip from "@mui/material/Chip"; -import FormControl from "@mui/material/FormControl"; +import IconButton from "@mui/material/IconButton"; import TextField from "@mui/material/TextField"; -import Select from "@mui/material/Select"; +import Checkbox from "@mui/material/Checkbox"; import MenuItem from "@mui/material/MenuItem"; import { theme } from "../../theme"; @@ -36,6 +36,8 @@ import { getPersonsApi } from "@jellyfin/sdk/lib/utils/api/persons-api"; import { Card } from "../../components/card/card"; import { EmptyNotice } from "../../components/emptyNotice/emptyNoticee"; +import { MdiSortDescending } from "../../components/icons/mdiSortDescending"; +import { MdiSortAscending } from "../../components/icons/mdiSortAscending"; const LibraryView = () => { const dispatch = useDispatch(); @@ -54,6 +56,20 @@ const LibraryView = () => { }, }); + const [sortAscending, setSortAscending] = useState(false); + const [sortBy, setSortBy] = useState("SortName"); + const [sortByData, setSortByData] = useState([ + { title: "Name", value: "SortName" }, + { title: "Rating", value: "CommunityRating" }, + { title: "Release Date", value: "PremiereDate" }, + ]); + const handleSortChange = (e) => { + setSortAscending(e.target.checked); + }; + const handleSortBy = (e) => { + setSortBy(e.target.value); + }; + const fetchLib = async (libraryId) => { const result = await getItemsApi(window.api).getItems({ userId: user.data.Id, @@ -78,26 +94,26 @@ const LibraryView = () => { if (currentLib.isSuccess) { if (currentLib.data.Items[0].CollectionType == "movies") { setViewType([ - { title: "movies", value: "Movie" }, - { title: "collections", value: "BoxSet" }, - { title: "actors", value: "Person" }, - { title: "genres", value: "Genre" }, - { title: "studios", value: "Studio" }, + { title: "Movies", value: "Movie" }, + { title: "Collections", value: "BoxSet" }, + { title: "Actors", value: "Person" }, + { title: "Genres", value: "Genre" }, + { title: "Studios", value: "Studio" }, ]); } else if (currentLib.data.Items[0].CollectionType == "music") { setViewType([ - { title: "albums", value: "MusicAlbum" }, - { title: "artists", value: "MusicArtist" }, - { title: "genres", value: "MusicGenre" }, + { title: "Albums", value: "MusicAlbum" }, + { title: "Artists", value: "MusicArtist" }, + { title: "Genres", value: "MusicGenre" }, ]); } else if ( currentLib.data.Items[0].CollectionType == "tvshows" ) { setViewType([ - { title: "series", value: "Series" }, - { title: "actors", value: "Person" }, - { title: "genres", value: "Genre" }, - { title: "networks", value: "Studio" }, + { title: "Series", value: "Series" }, + { title: "Actors", value: "Person" }, + { title: "Genres", value: "Genre" }, + { title: "Networks", value: "Studio" }, ]); } else { setViewType([]); @@ -139,13 +155,20 @@ const LibraryView = () => { parentId: libraryId, recursive: true, includeItemTypes: [currentViewType], + sortOrder: [sortAscending ? "Ascending" : "Descending"], + sortBy: sortBy, }); } return result.data; }; const items = useQuery({ - queryKey: ["libraryView", "currentLibItems", id, currentViewType], + queryKey: [ + "libraryView", + "currentLibItems", + id, + `${currentViewType} - ${sortAscending} - ${sortBy}`, + ], queryFn: () => fetchLibItems(id), enabled: !!user.data, }); @@ -154,13 +177,14 @@ const LibraryView = () => { const handleCurrentViewType = (e) => { setCurrentViewType(e.target.value); - console.log(e.target.value); }; useEffect(() => { if (viewType.length != 0) setCurrentViewType(viewType[0].value); }, [viewType]); + const allowedSortViews = ["Movie", "Series", "MusicAlbum"]; + return ( { }} > - - - {currentLib.isLoading ? ( - - ) : ( - currentLib.data.Items[0].Name - )} - - + + + {currentLib.isLoading ? ( ) : ( - items.data.TotalRecordCount - ) - } - /> + currentLib.data.Items[0].Name + )} + + + ) : ( + items.data.TotalRecordCount + ) + } + /> + {/* Age */} - {viewType.length != 0 && ( - - {viewType.map((item, index) => { - return ( - - {item.title} - - ); - })} - - )} + + } + > + {allowedSortViews.includes( + currentViewType, + ) && ( + <> + } + checkedIcon={ + + } + color="white" + onChange={handleSortChange} + defaultValue={sortAscending} + /> + + {sortByData.map( + (item, index) => { + return ( + + {`By ${item.title}`} + + ); + }, + )} + + + )} + {viewType.length != 0 && ( + + {viewType.map((item, index) => { + return ( + + {item.title} + + ); + })} + + )} + @@ -277,6 +356,17 @@ const LibraryView = () => { ? "square" : "portait" } + watchedStatus={ + !!item.UserData + ? item.UserData + .Played + : false + } + watchedCount={ + !!item.UserData && + item.UserData + .UnplayedItemCount + } > );