Display songs in libView and update titlePage #9 #26

This commit is contained in:
prayag17 committed 2023-04-24 14:49:05 +05:30
1 parent ed1633fb21
commit 53f042a453
10 files changed
+391 -103

No files matched your search

-11
View File
@@ -137,13 +137,8 @@ function App() {
const server = await getServer();
if (server == null) {
console.log("server not found");
return false;
} else {
// if (!window.api) {
// console.log("Creating Jf api (without accessToken)");
// event.emit("create-jellyfin-api", server.Ip);
// }
return true;
}
};
@@ -159,7 +154,6 @@ function App() {
const userSaved = async () => {
const user = await getUser();
console.log("User store => ", user);
if (user == null) {
return false;
} else {
@@ -189,7 +183,6 @@ function App() {
})
.catch((error) => {
setServerReachable(false);
console.error(error);
setChecking(false);
});
};
@@ -253,22 +246,18 @@ function App() {
const handleRelaunch = async () => {
let result = await relaunch();
console.log(result);
};
const handleRemoveServer = async () => {
await delServer();
await delUser();
let result = await relaunch();
console.log(result);
};
const location = useLocation();
if (!window.api) {
console.log("WindowAPi not present");
serverAvailable().then((available) => {
if (available) {
console.log(available);
createApi().then(
userSaved().then((userSavedBool) => {
if (userSavedBool) {
+8 -8
View File
@@ -51,7 +51,7 @@ export const Card = ({
const navigate = useNavigate();
const [imgLoading, setImgLoading] = useState(true);
const [isWatched, setIsWatched] = useState(watchedStatus);
const [isFavourite, setIsFavourite] = useState(favourite);
const [isFavorite, setisFavorite] = useState(favourite);
const [watchedCountState, setWatchedCountState] = useState(watchedCount);
const handleMarkAsPlayOrUnMarkAsPlay = async () => {
let result;
@@ -71,18 +71,18 @@ export const Card = ({
};
const handleLiking = async () => {
let result;
if (isFavourite) {
if (isFavorite) {
result = await getUserLibraryApi(window.api).unmarkFavoriteItem({
userId: currentUser.Id,
itemId: itemId,
});
} else if (!isFavourite) {
} else if (!isFavorite) {
result = await getUserLibraryApi(window.api).markFavoriteItem({
userId: currentUser.Id,
itemId: itemId,
});
}
setIsFavourite(result.data.IsFavorite);
setisFavorite(result.data.IsFavorite);
};
const availableMarkButtonTypes = [
@@ -214,7 +214,7 @@ export const Card = ({
window.api.basePath +
"/Items/" +
itemId +
"/Images/Primary"
"/Images/Primary?fillHeight=532&fillWidth=300&quality=96"
}
alt={itemName}
sx={{
@@ -240,8 +240,8 @@ export const Card = ({
hash={blurhash}
width="100%"
height="100%"
resolutionX={64}
resolutionY={64}
resolutionX={24}
resolutionY={24}
style={{
aspectRatio:
cardOrientation == "landscape"
@@ -311,7 +311,7 @@ export const Card = ({
handleLiking();
}}
>
{isFavourite ? (
{isFavorite ? (
<MdiHeart
sx={{ color: pink[700] }}
/>
+4 -11
View File
@@ -56,7 +56,6 @@ export const EpisodeCard = ({
parentId,
}) => {
const navigate = useNavigate();
const [imgLoading, setImgLoading] = useState(true);
const [isWatched, setIsWatched] = useState(watchedStatus);
const [isFavourite, setIsFavourite] = useState(favourite);
const handleMarkAsPlayOrUnMarkAsPlay = async () => {
@@ -72,7 +71,6 @@ export const EpisodeCard = ({
itemId: itemId,
});
}
console.log(result.data);
setIsWatched(result.data.Played);
};
const handleLiking = async () => {
@@ -88,7 +86,6 @@ export const EpisodeCard = ({
itemId: itemId,
});
}
console.log(result.data.IsFavorite);
setIsFavourite(result.data.IsFavorite);
};
@@ -132,13 +129,10 @@ export const EpisodeCard = ({
opacity: isWatched ? 1 : 0,
}}
/>
<Box
className="card-media-image-container"
sx={{ opacity: imgLoading ? 0 : 1 }}
>
<Box className="card-media-image-container">
{imageTags && (
<CardMedia
component="img"
component="div"
image={
window.api.basePath +
"/Items/" +
@@ -153,7 +147,6 @@ export const EpisodeCard = ({
borderRadiusDefault,
overflow: "hidden",
}}
onLoad={() => setImgLoading(false)}
className="card-image"
></CardMedia>
)}
@@ -163,8 +156,8 @@ export const EpisodeCard = ({
hash={blurhash}
width="100%"
height="100%"
resolutionX={512}
resolutionY={910}
resolutionX={12}
resolutionY={18}
style={{
aspectRatio: "1.777",
}}
-1
View File
@@ -101,7 +101,6 @@ export const SideMenu = ({}) => {
};
useEffect(() => {
console.log(location.pathname.includes("login"));
if (
location.pathname.includes("login") ||
location.pathname.includes("setup")
+2 -3
View File
@@ -253,7 +253,6 @@ const Home = () => {
// <></>
latestMedia.data != null &&
latestMedia.data.map((item, index) => {
// console.log(item);
return (
<Paper
className="hero-carousel-slide"
@@ -281,10 +280,10 @@ const Home = () => {
width="1080"
height="720"
resolutionX={
720
64
}
resolutionY={
1080
96
}
className="hero-carousel-background-blurhash"
/>
+191 -43
View File
@@ -21,6 +21,8 @@ import TableHead from "@mui/material/TableHead";
import TableRow from "@mui/material/TableRow";
import TableBody from "@mui/material/TableBody";
import TableCell from "@mui/material/TableCell";
import TextField from "@mui/material/TextField";
import MenuItem from "@mui/material/MenuItem";
import { green, pink } from "@mui/material/colors";
import { AvatarImage } from "../../components/avatar/avatar";
@@ -37,6 +39,7 @@ import { getLibraryApi } from "@jellyfin/sdk/lib/utils/api/library-api";
import { getTvShowsApi } from "@jellyfin/sdk/lib/utils/api/tv-shows-api";
import { getItemsApi } from "@jellyfin/sdk/lib/utils/api/items-api";
import { getPlaystateApi } from "@jellyfin/sdk/lib/utils/api/playstate-api";
import { getVideosApi } from "@jellyfin/sdk/lib/utils/api/videos-api";
import { useQuery } from "@tanstack/react-query";
@@ -303,6 +306,18 @@ const ItemDetail = () => {
networkMode: "always",
});
// const videoStreams = useQuery({
// queryKey: ["item", id, "videoTracks"],
// queryFn: async () => {
// const result = await getVideosApi(window.api).getVideoStream({
// itemId: item.data.Id,
// });
// return result.data;
// },
// enabled: item.isSuccess,
// networkMode: "always",
// });
const handleMarkPlayedOrunPlayed = async () => {
let result;
if (!item.data.UserData.Played) {
@@ -325,7 +340,6 @@ const ItemDetail = () => {
userId: user.data.Id,
itemId: item.data.Id,
});
console.log(result.statusText);
} else if (!item.data.UserData.IsFavorite) {
result = await getUserLibraryApi(window.api).markFavoriteItem({
userId: user.data.Id,
@@ -341,7 +355,6 @@ const ItemDetail = () => {
userId: user.data.Id,
itemId: track.Id,
});
console.log(result.statusText);
} else if (!track.UserData.IsFavorite) {
result = await getUserLibraryApi(window.api).markFavoriteItem({
userId: user.data.Id,
@@ -412,8 +425,8 @@ const ItemDetail = () => {
}
width="100%"
height="100%"
resolutionX={64}
resolutionY={96}
resolutionX={14}
resolutionY={22}
style={{
aspectRatio: "0.666",
}}
@@ -436,25 +449,50 @@ const ItemDetail = () => {
>
<Box className="item-detail-header" mb={0}>
<Box className="item-detail-header-backdrop">
{item.data.BackdropImageTags.length != 0 && (
<img
src={
window.api.basePath +
"/Items/" +
item.data.Id +
"/Images/Backdrop"
}
style={{
opacity: backdropImageLoaded
? 1
: 0,
}}
className="item-detail-image"
onLoad={() =>
setBackdropImageLoaded(true)
}
/>
)}
{item.data.Type != BaseItemKind.MusicAlbum
? item.data.BackdropImageTags.length !=
0 && (
<img
src={
item.data.Type ==
BaseItemKind.MusicAlbum
? `${window.api.basePath}/Items/${item.data.ParentBackdropItemId}/Images/Backdrop`
: `${window.api.basePath}/Items/${item.data.Id}/Images/Backdrop`
}
style={{
opacity: backdropImageLoaded
? 1
: 0,
}}
className="item-detail-image"
onLoad={() =>
setBackdropImageLoaded(
true,
)
}
/>
)
: !!item.data.ParentBackdropItemId && (
<img
src={
item.data.Type ==
BaseItemKind.MusicAlbum
? `${window.api.basePath}/Items/${item.data.ParentBackdropItemId}/Images/Backdrop`
: `${window.api.basePath}/Items/${item.data.Id}/Images/Backdrop`
}
style={{
opacity: backdropImageLoaded
? 1
: 0,
}}
className="item-detail-image"
onLoad={() =>
setBackdropImageLoaded(
true,
)
}
/>
)}
{item.data.BackdropImageTags.length != 0 && (
<Blurhash
hash={
@@ -466,8 +504,8 @@ const ItemDetail = () => {
}
width="100%"
height="100%"
resolutionX={64}
resolutionY={96}
resolutionX={12}
resolutionY={18}
style={{
aspectRatio: "0.666",
}}
@@ -522,7 +560,7 @@ const ItemDetail = () => {
window.api.basePath +
"/Items/" +
item.data.Id +
"/Images/Primary?quality=10"
"/Images/Primary?fillHeight=532&fillWidth=300&quality=96"
}
style={{
opacity: primageImageLoaded
@@ -549,8 +587,8 @@ const ItemDetail = () => {
}
width="100%"
height="100%"
resolutionX={64}
resolutionY={96}
resolutionX={12}
resolutionY={8}
style={{
aspectRatio: 0.666,
}}
@@ -773,7 +811,7 @@ const ItemDetail = () => {
</Box>
</Box>
{item.data.Genres != 0 && (
<Box sx={{ mb: 2 }}>
<Box sx={{ mb: 2, width: "50%" }}>
<Stack
direction="row"
gap={1}
@@ -815,19 +853,134 @@ const ItemDetail = () => {
>
Artists
</Typography>
{item.data.Artists.map((mitem, mindex) => {
return (
<Typography
key={mindex}
variant="h6"
>
{mitem}
<Stack
direction="row"
gap={0.5}
divider={
<Typography variant="h6">
,
</Typography>
);
})}
}
>
{item.data.Artists.map(
(mitem, mindex) => {
return (
<Typography
key={mindex}
variant="h6"
>
{mitem}
</Typography>
);
},
)}
</Stack>
</Stack>
)}
{!!item.data.MediaStreams &&
item.data.MediaStreams.length != 0 && (
<>
<Box sx={{ mb: 2, width: "50%" }}>
<Stack
direction="row"
gap={1}
alignItems="center"
>
<Typography
className="item-detail-heading"
variant="h5"
mr={2}
>
Video
</Typography>
<TextField
defaultValue={
item.data
.MediaStreams[0]
.DisplayTitle
}
select
fullWidth
hiddenLabel
>
{item.data.MediaStreams.map(
(
stream,
sindex,
) => {
if (
stream.Type ==
BaseItemKind.Video
)
return (
<MenuItem
key={
sindex
}
value={
stream.DisplayTitle
}
>
{
stream.DisplayTitle
}
</MenuItem>
);
},
)}
</TextField>
</Stack>
</Box>
<Box sx={{ mb: 2, width: "50%" }}>
<Stack
direction="row"
gap={1}
alignItems="center"
>
<Typography
className="item-detail-heading"
variant="h5"
mr={2}
>
Audio
</Typography>
<TextField
select
fullWidth
hiddenLabel
>
{item.data.MediaStreams.map(
(
stream,
sindex,
) => {
if (
stream.Type ==
BaseItemKind.Audio
)
return (
<MenuItem
key={
sindex
}
value={
stream.DisplayTitle
}
>
{
stream.DisplayTitle
}
</MenuItem>
);
},
)}
</TextField>
</Stack>
</Box>
</>
)}
{!!item.data.Overview && (
<Box mt={3}>
<Typography variant="h5" mb={1}>
@@ -1558,11 +1711,6 @@ const ItemDetail = () => {
.UserData
.Played
}
watchedCount={
mitem
.UserData
.PlayCount
}
blurhash={
mitem.ImageBlurHashes ==
{}
+4 -3
View File
@@ -39,10 +39,11 @@
}
}
&-image {
position: absolute;
width: 100%;
height: 100%;
object-fit: cover;
position: absolute;
object-position: top;
transition: opacity $transition-time-default;
&-blurhash {
z-index: -1;
@@ -71,8 +72,8 @@
}
&-title-logo {
filter: drop-shadow(0 0 10px rgb(0 0 0 /0.2));
max-width: 75%;
height: 2em;
height: 100%;
width: 45%;
object-fit: contain;
object-position: bottom;
}
+134 -21
View File
@@ -24,10 +24,17 @@ import Accordion from "@mui/material/Accordion";
import AccordionSummary from "@mui/material/AccordionSummary";
import AccordionDetails from "@mui/material/AccordionDetails";
import Button from "@mui/material/Button";
import Paper from "@mui/material/Paper";
import Table from "@mui/material/Table";
import TableContainer from "@mui/material/TableContainer";
import TableRow from "@mui/material/TableRow";
import TableCell from "@mui/material/TableCell";
import IconButton from "@mui/material/IconButton";
import { theme } from "../../theme";
import { getUserApi } from "@jellyfin/sdk/lib/utils/api/user-api";
import { getUserLibraryApi } from "@jellyfin/sdk/lib/utils/api/user-library-api";
import { getItemsApi } from "@jellyfin/sdk/lib/utils/api/items-api";
import { getArtistsApi } from "@jellyfin/sdk/lib/utils/api/artists-api";
import { getGenresApi } from "@jellyfin/sdk/lib/utils/api/genres-api";
@@ -45,6 +52,16 @@ import { MdiFilterOutline } from "../../components/icons/mdiFilterOutline";
import { clrBackgroundDarkOpacity0_8 } from "../../palette.module.scss";
import { ErrorNotice } from "../../components/notices/errorNotice/errorNotice";
import {
BaseItemKind,
CollectionTypeOptions,
} from "@jellyfin/sdk/lib/generated-client";
import { getRuntimeMusic } from "../../utils/date/time";
import "./library.module.scss";
import { MdiMusic } from "../../components/icons/mdiMusic";
import { MdiHeart } from "../../components/icons/mdiHeart";
import { MdiHeartOutline } from "../../components/icons/mdiHeartOutline";
const LibraryView = () => {
const navigate = useNavigate();
@@ -64,12 +81,17 @@ const LibraryView = () => {
},
});
const [sortAscending, setSortAscending] = useState(false);
const [sortAscending, setSortAscending] = useState(true);
const [sortBy, setSortBy] = useState("SortName");
const [sortByData, setSortByData] = useState([
{ title: "Name", value: "SortName" },
{ title: "Critic Rating", value: "CriticRating" },
{ title: "Rating", value: "CommunityRating" },
{ title: "Release Date", value: "PremiereDate" },
{ title: "Date Added", value: "DateCreated" },
{ title: "Play Count", value: "PlayCount" },
{ title: "Runtime", value: "Runtime" },
{ title: "Random", value: "Random" },
]);
const handleSortChange = (e) => {
setSortAscending(e.target.checked);
@@ -98,7 +120,7 @@ const LibraryView = () => {
const [isPlayed, setIsPlayed] = useState(false);
const [isUnPlayed, setIsUnPlayed] = useState(false);
const [isResumable, setIsResumable] = useState(false);
const [isFavourite, setIsFavourite] = useState(false);
const [isFavorite, setisFavorite] = useState(false);
const [isLiked, setIsLiked] = useState(false);
const [isUnliked, setIsUnliked] = useState(false);
const availableWatchStatus = [
@@ -120,7 +142,7 @@ const LibraryView = () => {
{
title: "Favourite",
value: false,
state: (val) => setIsFavourite(val),
state: (val) => setisFavorite(val),
},
{
title: "Liked",
@@ -186,26 +208,27 @@ 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: BaseItemKind.Movie },
{ title: "Collections", value: BaseItemKind.BoxSet },
{ title: "Actors", value: BaseItemKind.Person },
{ title: "Genres", value: BaseItemKind.Genre },
{ title: "Studios", value: BaseItemKind.Studio },
]);
} else if (currentLib.data.Items[0].CollectionType == "music") {
setViewType([
{ title: "Albums", value: "MusicAlbum" },
{ title: "Artists", value: "MusicArtist" },
{ title: "Genres", value: "MusicGenre" },
{ title: "Songs", value: BaseItemKind.Audio },
{ title: "Albums", value: BaseItemKind.MusicAlbum },
{ title: "Artists", value: BaseItemKind.MusicArtist },
{ title: "Genres", value: BaseItemKind.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: BaseItemKind.Series },
{ title: "Actors", value: BaseItemKind.Person },
{ title: "Genres", value: BaseItemKind.Genre },
{ title: "Networks", value: BaseItemKind.Studio },
]);
} else {
setViewType([]);
@@ -260,7 +283,7 @@ const LibraryView = () => {
isPlayed && "IsPlayed",
isUnPlayed && "IsUnplayed",
isResumable && "IsResumable",
isFavourite && "IsFavorite",
isFavorite && "IsFavorite",
isLiked && "IsFavoriteOrLikes",
isUnliked && "Dislikes",
],
@@ -291,7 +314,7 @@ const LibraryView = () => {
isPlayed,
isUnPlayed,
isResumable,
isFavourite,
isFavorite,
isLiked,
isUnliked,
],
@@ -343,6 +366,22 @@ const LibraryView = () => {
threshold: 1,
});
const handleLiking = async (item) => {
let result;
if (item.UserData.isFavorite) {
result = await getUserLibraryApi(window.api).unmarkFavoriteItem({
userId: user.data.Id,
itemId: item.Id,
});
} else if (!item.UserData.isFavorite) {
result = await getUserLibraryApi(window.api).markFavoriteItem({
userId: user.data.Id,
itemId: item.Id,
});
}
items.refetch();
};
return (
<Box
sx={{
@@ -708,12 +747,12 @@ const LibraryView = () => {
checkedIcon={
<MdiSortAscending />
}
color="white"
onChange={handleSortChange}
defaultValue={sortAscending}
sx={{
color: "white !important",
}}
color="white"
onChange={handleSortChange}
defaultValue={sortAscending}
/>
<TextField
select
@@ -771,7 +810,7 @@ const LibraryView = () => {
{items.isSuccess &&
(items.data.TotalRecordCount == 0 ? (
<EmptyNotice />
) : (
) : currentViewType != BaseItemKind.Audio ? (
<Grid2
container
columns={{ xs: 2, sm: 4, md: 8 }}
@@ -850,6 +889,80 @@ const LibraryView = () => {
);
})}
</Grid2>
) : (
<TableContainer>
<Table>
{items.data.Items.map((item, index) => {
return (
<TableRow
key={index}
sx={{
"& td,& th": {
borderBottom:
"1px solid rgb(255 255 255 / 0.1)",
},
"&:hover": {
background:
"rgb(255 255 255 / 0.05)",
},
}}
>
<TableCell width="4.5em">
<Box className="library-list-image-container">
{!!item
.ImageTags
.Primary && (
<img
className="library-list-image"
src={`${window.api.basePath}/Items/${item.Id}/Images/Primary?quality=80&tag=${item.ImageTags.Primary}`}
/>
)}
<Box className="library-list-icon-container">
<MdiMusic className="library-list-icon" />
</Box>
</Box>
</TableCell>
<TableCell>
<Typography variant="h6">
{item.Name}
</Typography>
<Typography
variant="subtitle1"
sx={{
opacity: 0.7,
}}
>
{item.Album}
</Typography>
</TableCell>
<TableCell>
<Typography variant="subtitle1">
{getRuntimeMusic(
item.RunTimeTicks,
)}
</Typography>
</TableCell>
<TableCell width="1em">
<IconButton
onClick={() => {
handleLiking(
item,
);
}}
>
{item.UserData
.IsFavorite ? (
<MdiHeart />
) : (
<MdiHeartOutline />
)}
</IconButton>
</TableCell>
</TableRow>
);
})}
</Table>
</TableContainer>
))}
{items.isError && <ErrorNotice />}
</Box>
+36
View File
@@ -0,0 +1,36 @@
/** @format */
.library-list {
&-image {
position: relative;
width: 100%;
height: 100%;
z-index: 1;
object-fit: cover;
&-container {
position: relative;
width: 4.5em;
height: 4.5em;
aspect-ratio: 1;
border-radius: $border-radius-intensity-1;
overflow: hidden;
box-shadow: 0 2px 7px rgb(0 0 0 / 0.2);
}
}
&-icon {
font-size: 3em;
fill: url(#clr-gradient-default) !important;
&-container {
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
display: flex;
justify-content: center;
align-items: center;
z-index: 0;
background: $clr-gradient-dark;
}
}
}
+12 -2
View File
@@ -40,12 +40,22 @@ export const getRuntimeMusic = (ticks) => {
let timeSec = Math.floor(time / 1000);
let timeMin = Math.floor(timeSec / 60);
timeSec -= timeMin * 60;
timeSec = timeSec == 0 ? 0o0 : timeSec;
if (timeMin > 60) {
let timeHr = Math.floor(timeMin / 60);
timeMin -= timeHr * 60;
formatedTime = `${timeHr}:${timeMin}`;
formatedTime = `${timeHr}:${timeMin.toLocaleString([], {
minimumIntegerDigits: 2,
useGrouping: false,
})}:${timeSec.toLocaleString([], {
minimumIntegerDigits: 2,
useGrouping: false,
})}`;
} else {
formatedTime = `${timeMin}:${timeSec}`;
formatedTime = `${timeMin}:${timeSec.toLocaleString([], {
minimumIntegerDigits: 2,
useGrouping: false,
})}`;
}
return formatedTime;
};