refactor: move to tanstack router
This commit is contained in:
136 files changed
+7063
-6127
No files matched your search
@@ -0,0 +1,247 @@
|
||||
import { AppBar } from "@/components/appBar/appBar";
|
||||
import NProgress from "@/components/nProgress";
|
||||
import AudioPlayer from "@/components/playback/audioPlayer";
|
||||
import Settings from "@/components/settings";
|
||||
import { EasterEgg } from "@/components/utils/easterEgg";
|
||||
import { useBackdropStore } from "@/utils/store/backdrop";
|
||||
import { LoadingButton } from "@mui/lab";
|
||||
import {
|
||||
Button,
|
||||
Chip,
|
||||
CssBaseline,
|
||||
Dialog,
|
||||
DialogActions,
|
||||
DialogContent,
|
||||
DialogContentText,
|
||||
DialogTitle,
|
||||
IconButton,
|
||||
SvgIcon,
|
||||
ThemeProvider,
|
||||
} from "@mui/material";
|
||||
import { useIsFetching, useIsMutating } from "@tanstack/react-query";
|
||||
import {
|
||||
Outlet,
|
||||
createRootRoute,
|
||||
createRootRouteWithContext,
|
||||
useNavigate,
|
||||
} from "@tanstack/react-router";
|
||||
import { TanStackRouterDevtools } from "@tanstack/router-devtools";
|
||||
import { relaunch } from "@tauri-apps/api/process";
|
||||
import {
|
||||
type UpdateManifest,
|
||||
checkUpdate,
|
||||
installUpdate,
|
||||
} from "@tauri-apps/api/updater";
|
||||
import { AnimatePresence, motion } from "framer-motion";
|
||||
import { SnackbarProvider, useSnackbar } from "notistack";
|
||||
import React, { Suspense, useEffect, useLayoutEffect, useState } from "react";
|
||||
import Markdown from "react-markdown";
|
||||
import remarkGfm from "remark-gfm";
|
||||
|
||||
import "../styles/global.scss";
|
||||
import { theme } from "@/theme";
|
||||
|
||||
// Fonts
|
||||
import "@fontsource-variable/jetbrains-mono";
|
||||
import "@fontsource-variable/noto-sans";
|
||||
|
||||
import "material-symbols/rounded.scss";
|
||||
import { ErrorNotice } from "@/components/notices/errorNotice/errorNotice";
|
||||
import type { Api } from "@jellyfin/sdk";
|
||||
import { ReactQueryDevtools } from "@tanstack/react-query-devtools";
|
||||
|
||||
type ApiContext = {
|
||||
api: Api;
|
||||
createApi: (
|
||||
serverAddress: string | undefined,
|
||||
accessToken: string | undefined,
|
||||
) => void;
|
||||
};
|
||||
|
||||
export const Route = createRootRouteWithContext<ApiContext>()({
|
||||
errorComponent: (error) => {
|
||||
console.error(error.error);
|
||||
},
|
||||
component: () => {
|
||||
const isQueryFetching = useIsFetching();
|
||||
const isMutating = useIsMutating();
|
||||
const [updateDialog, setUpdateDialog] = useState(false);
|
||||
const [updateDialogButton, setUpdateDialogButton] = useState(false);
|
||||
const [updateInfo, setUpdateInfo] = useState<UpdateManifest | undefined>(
|
||||
undefined,
|
||||
);
|
||||
useLayoutEffect(() => {
|
||||
async function checkForUpdates() {
|
||||
try {
|
||||
const { shouldUpdate, manifest } = await checkUpdate();
|
||||
|
||||
if (shouldUpdate) {
|
||||
setUpdateInfo(manifest);
|
||||
setUpdateDialog(true);
|
||||
|
||||
console.log(
|
||||
`Update found : ${manifest?.version}, ${manifest?.date}`,
|
||||
);
|
||||
}
|
||||
} catch (error) {
|
||||
console.error(error);
|
||||
}
|
||||
}
|
||||
checkForUpdates();
|
||||
}, []);
|
||||
const { enqueueSnackbar } = useSnackbar();
|
||||
const [backdropUrl, backdropId] = useBackdropStore((state) => [
|
||||
state.backdropUrl,
|
||||
state.backdropId,
|
||||
]);
|
||||
|
||||
const [backdropLoading, setBackdropLoading] = useState(true);
|
||||
// Reset BackdropImageLoading for every new image
|
||||
useEffect(() => {
|
||||
setBackdropLoading(true);
|
||||
}, [backdropId]);
|
||||
return (
|
||||
<Suspense fallback={<h1>Loading...</h1>}>
|
||||
<ThemeProvider theme={theme}>
|
||||
<SnackbarProvider maxSnack={5}>
|
||||
<CssBaseline />
|
||||
<Settings />
|
||||
<EasterEgg />
|
||||
<NProgress isAnimating={isQueryFetching || isMutating} />
|
||||
<Dialog
|
||||
open={updateDialog}
|
||||
fullWidth
|
||||
PaperProps={{
|
||||
style: {
|
||||
borderRadius: "14px",
|
||||
background: "rgb(0 0 0 / 0.5)",
|
||||
backdropFilter: "blur(10px)",
|
||||
border: "1px solid rgb(255 255 255 / 0.2)",
|
||||
},
|
||||
}}
|
||||
sx={{
|
||||
"& img": {
|
||||
width: "100%",
|
||||
},
|
||||
}}
|
||||
>
|
||||
{updateInfo !== undefined && (
|
||||
<>
|
||||
<DialogTitle
|
||||
variant="h5"
|
||||
style={{
|
||||
display: "flex",
|
||||
flexDirection: "column",
|
||||
alignItems: "flex-start",
|
||||
gap: "0.4em",
|
||||
}}
|
||||
>
|
||||
Update Available!
|
||||
<Chip
|
||||
icon={
|
||||
<span className="material-symbols-rounded">update</span>
|
||||
}
|
||||
label={`v${updateInfo.version}`}
|
||||
color="success"
|
||||
/>
|
||||
</DialogTitle>
|
||||
<DialogContent dividers>
|
||||
<DialogContentText>
|
||||
<Markdown remarkPlugins={[remarkGfm]}>
|
||||
{updateInfo.body}
|
||||
</Markdown>
|
||||
</DialogContentText>
|
||||
</DialogContent>
|
||||
<DialogActions
|
||||
style={{
|
||||
padding: "1em",
|
||||
}}
|
||||
>
|
||||
<IconButton
|
||||
disabled={updateDialogButton}
|
||||
target="_blank"
|
||||
href={`https://github.com/prayag17/JellyPlayer/releases/${updateInfo.version}`}
|
||||
>
|
||||
<SvgIcon>
|
||||
<svg
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
width="16"
|
||||
height="16"
|
||||
fill="currentColor"
|
||||
viewBox="0 0 16 16"
|
||||
>
|
||||
<title>Update</title>
|
||||
<path d="M8 0C3.58 0 0 3.58 0 8c0 3.54 2.29 6.53 5.47 7.59.4.07.55-.17.55-.38 0-.19-.01-.82-.01-1.49-2.01.37-2.53-.49-2.69-.94-.09-.23-.48-.94-.82-1.13-.28-.15-.68-.52-.01-.53.63-.01 1.08.58 1.23.82.72 1.21 1.87.87 2.33.66.07-.52.28-.87.51-1.07-1.78-.2-3.64-.89-3.64-3.95 0-.87.31-1.59.82-2.15-.08-.2-.36-1.02.08-2.12 0 0 .67-.21 2.2.82.64-.18 1.32-.27 2-.27.68 0 1.36.09 2 .27 1.53-1.04 2.2-.82 2.2-.82.44 1.1.16 1.92.08 2.12.51.56.82 1.27.82 2.15 0 3.07-1.87 3.75-3.65 3.95.29.25.54.73.54 1.48 0 1.07-.01 1.93-.01 2.2 0 .21.15.46.55.38A8.012 8.012 0 0 0 16 8c0-4.42-3.58-8-8-8" />
|
||||
</svg>
|
||||
</SvgIcon>
|
||||
</IconButton>
|
||||
<Button
|
||||
size="large"
|
||||
color="error"
|
||||
variant="outlined"
|
||||
disabled={updateDialogButton}
|
||||
onClick={() => setUpdateDialog(false)}
|
||||
>
|
||||
close
|
||||
</Button>
|
||||
<LoadingButton
|
||||
size="large"
|
||||
color="success"
|
||||
variant="contained"
|
||||
loading={updateDialogButton}
|
||||
loadingIndicator="Updating..."
|
||||
onClick={async () => {
|
||||
setUpdateDialogButton(true);
|
||||
await installUpdate();
|
||||
enqueueSnackbar(
|
||||
"Update has been installed! You need to relaunch JellyPlayer.",
|
||||
{
|
||||
variant: "success",
|
||||
},
|
||||
);
|
||||
await relaunch();
|
||||
}}
|
||||
>
|
||||
Update
|
||||
</LoadingButton>
|
||||
</DialogActions>
|
||||
</>
|
||||
)}
|
||||
</Dialog>
|
||||
<div className="app-backdrop-container">
|
||||
<AnimatePresence>
|
||||
<motion.img
|
||||
key={backdropId}
|
||||
src={backdropUrl}
|
||||
alt=""
|
||||
className="app-backdrop"
|
||||
initial={{
|
||||
opacity: 0,
|
||||
}}
|
||||
animate={{
|
||||
opacity: backdropLoading ? 0 : 1,
|
||||
}}
|
||||
exit={{
|
||||
opacity: 0,
|
||||
}}
|
||||
transition={{
|
||||
opacity: {
|
||||
duration: 1.2,
|
||||
},
|
||||
}}
|
||||
onLoad={() => setBackdropLoading(false)}
|
||||
loading="lazy"
|
||||
/>
|
||||
</AnimatePresence>
|
||||
</div>
|
||||
<AppBar />
|
||||
<AudioPlayer />
|
||||
<Outlet />
|
||||
<ReactQueryDevtools />
|
||||
<TanStackRouterDevtools />
|
||||
</SnackbarProvider>
|
||||
</ThemeProvider>
|
||||
</Suspense>
|
||||
);
|
||||
},
|
||||
});
|
||||
@@ -0,0 +1,28 @@
|
||||
import {
|
||||
getAllServers,
|
||||
getDefaultServer,
|
||||
getServer,
|
||||
} from "@/utils/storage/servers";
|
||||
import { getUser } from "@/utils/storage/user";
|
||||
import { axiosClient } from "@/utils/store/api";
|
||||
import { getUserApi } from "@jellyfin/sdk/lib/utils/api/user-api";
|
||||
import { Outlet, createFileRoute, redirect } from "@tanstack/react-router";
|
||||
import React from "react";
|
||||
import { Suspense } from "react";
|
||||
|
||||
export const Route = createFileRoute("/_api")({
|
||||
beforeLoad: async ({ context, location }) => {
|
||||
if (!context.api) {
|
||||
const currentServerId = await getDefaultServer();
|
||||
if (currentServerId) {
|
||||
const currentServer = await getServer(currentServerId);
|
||||
const userOnDisk = await getUser();
|
||||
if (userOnDisk) {
|
||||
context.createApi(currentServer?.address, userOnDisk.AccessToken);
|
||||
} else {
|
||||
context.createApi(currentServer?.address, undefined); // Creates Api
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
});
|
||||
@@ -1,25 +1,17 @@
|
||||
import PropTypes from "prop-types";
|
||||
import React, { useEffect, useLayoutEffect, useRef } from "react";
|
||||
import React, { useLayoutEffect, useRef } from "react";
|
||||
|
||||
import heroBg from "@/assets/herobg.png";
|
||||
import Box from "@mui/material/Box";
|
||||
import Chip from "@mui/material/Chip";
|
||||
import CircularProgress from "@mui/material/CircularProgress";
|
||||
import Divider from "@mui/material/Divider";
|
||||
import Paper from "@mui/material/Paper";
|
||||
import Stack from "@mui/material/Stack";
|
||||
import Typography from "@mui/material/Typography";
|
||||
import heroBg from "../../assets/herobg.png";
|
||||
|
||||
import { Link, NavLink, useParams } from "react-router-dom";
|
||||
|
||||
import useParallax from "@/utils/hooks/useParallax";
|
||||
import { motion, useScroll } from "framer-motion";
|
||||
import useParallax from "../../utils/hooks/useParallax";
|
||||
|
||||
import {
|
||||
BaseItemKind,
|
||||
ItemFields,
|
||||
SortOrder,
|
||||
} from "@jellyfin/sdk/lib/generated-client";
|
||||
import { BaseItemKind, SortOrder } from "@jellyfin/sdk/lib/generated-client";
|
||||
import { getItemsApi } from "@jellyfin/sdk/lib/utils/api/items-api";
|
||||
import { getLibraryApi } from "@jellyfin/sdk/lib/utils/api/library-api";
|
||||
import { getUserApi } from "@jellyfin/sdk/lib/utils/api/user-api";
|
||||
@@ -29,25 +21,24 @@ import { Blurhash } from "react-blurhash";
|
||||
|
||||
import { useQuery } from "@tanstack/react-query";
|
||||
|
||||
import { endsAt, getRuntime, getRuntimeMusic } from "../../utils/date/time";
|
||||
import { getRuntime } from "@/utils/date/time";
|
||||
|
||||
import { Card } from "../../components/card/card";
|
||||
import { CardScroller } from "../../components/cardScroller/cardScroller";
|
||||
import { Card } from "@/components/card/card";
|
||||
import { CardScroller } from "@/components/cardScroller/cardScroller";
|
||||
|
||||
import LikeButton from "../../components/buttons/likeButton";
|
||||
import MarkPlayedButton from "../../components/buttons/markPlayedButton";
|
||||
import PlayButton from "../../components/buttons/playButton";
|
||||
import TrackList from "../../components/layouts/tracksList";
|
||||
import { ErrorNotice } from "../../components/notices/errorNotice/errorNotice";
|
||||
import ShowMoreText from "../../components/showMoreText";
|
||||
import LikeButton from "@/components/buttons/likeButton";
|
||||
import PlayButton from "@/components/buttons/playButton";
|
||||
import TrackList from "@/components/layouts/tracksList";
|
||||
import { ErrorNotice } from "@/components/notices/errorNotice/errorNotice";
|
||||
import ShowMoreText from "@/components/showMoreText";
|
||||
|
||||
import { getTypeIcon } from "../../components/utils/iconsCollection";
|
||||
import { useApi } from "../../utils/store/api";
|
||||
import { useAudioPlayback } from "../../utils/store/audioPlayback";
|
||||
import { useBackdropStore } from "../../utils/store/backdrop";
|
||||
import { getTypeIcon } from "@/components/utils/iconsCollection";
|
||||
import { useAudioPlayback } from "@/utils/store/audioPlayback";
|
||||
import { useBackdropStore } from "@/utils/store/backdrop";
|
||||
import "./album.scss";
|
||||
|
||||
import IconLink from "../../components/iconLink";
|
||||
import IconLink from "@/components/iconLink";
|
||||
import { createFileRoute } from "@tanstack/react-router";
|
||||
|
||||
function TabPanel(props) {
|
||||
const { children, value, index, ...other } = props;
|
||||
@@ -79,9 +70,13 @@ function a11yProps(index) {
|
||||
};
|
||||
}
|
||||
|
||||
const MusicAlbumTitlePage = () => {
|
||||
const { id } = useParams();
|
||||
const [api] = useApi((state) => [state.api]);
|
||||
export const Route = createFileRoute("/_api/album/$id")({
|
||||
component: MusicAlbumTitlePage,
|
||||
});
|
||||
|
||||
function MusicAlbumTitlePage() {
|
||||
const { id } = Route.useParams();
|
||||
const api = Route.useRouteContext().api;
|
||||
|
||||
const user = useQuery({
|
||||
queryKey: ["user"],
|
||||
@@ -97,9 +92,8 @@ const MusicAlbumTitlePage = () => {
|
||||
queryKey: ["item", id],
|
||||
queryFn: async () => {
|
||||
const result = await getUserLibraryApi(api).getItem({
|
||||
userId: user.data.Id,
|
||||
userId: user.data?.Id,
|
||||
itemId: id,
|
||||
fields: [ItemFields.Crew],
|
||||
});
|
||||
return result.data;
|
||||
},
|
||||
@@ -112,8 +106,8 @@ const MusicAlbumTitlePage = () => {
|
||||
queryKey: ["item", id, "similarItem"],
|
||||
queryFn: async () => {
|
||||
const result = await getLibraryApi(api).getSimilarAlbums({
|
||||
userId: user.data.Id,
|
||||
itemId: item.data.Id,
|
||||
userId: user.data?.Id,
|
||||
itemId: item.data?.Id,
|
||||
limit: 16,
|
||||
});
|
||||
return result.data;
|
||||
@@ -127,10 +121,10 @@ const MusicAlbumTitlePage = () => {
|
||||
queryKey: ["item", id, "musicTracks"],
|
||||
queryFn: async () => {
|
||||
const result = await getItemsApi(api).getItems({
|
||||
userId: user.data.Id,
|
||||
parentId: item.data.Id,
|
||||
sortOrder: SortOrder.Ascending,
|
||||
sortBy: "IndexNumber",
|
||||
userId: user.data?.Id,
|
||||
parentId: item.data?.Id,
|
||||
sortOrder: [SortOrder.Ascending],
|
||||
sortBy: ["IndexNumber"],
|
||||
});
|
||||
return result.data;
|
||||
},
|
||||
@@ -504,6 +498,6 @@ const MusicAlbumTitlePage = () => {
|
||||
if (item.isError || similarItems.isError) {
|
||||
return <ErrorNotice />;
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
export default MusicAlbumTitlePage;
|
||||
File renamed without changes.
@@ -8,10 +8,8 @@ import Tab from "@mui/material/Tab";
|
||||
import Tabs from "@mui/material/Tabs";
|
||||
import Typography from "@mui/material/Typography";
|
||||
|
||||
import useParallax from "@/utils/hooks/useParallax";
|
||||
import { AnimatePresence, motion, useScroll } from "framer-motion";
|
||||
import useParallax from "../../utils/hooks/useParallax";
|
||||
|
||||
import { Link, useParams } from "react-router-dom";
|
||||
|
||||
import {
|
||||
BaseItemKind,
|
||||
@@ -24,21 +22,21 @@ import { getUserLibraryApi } from "@jellyfin/sdk/lib/utils/api/user-library-api"
|
||||
|
||||
import { useQuery } from "@tanstack/react-query";
|
||||
|
||||
import LikeButton from "@/components/buttons/likeButton";
|
||||
import { Card } from "@/components/card/card";
|
||||
import { Blurhash } from "react-blurhash";
|
||||
import LikeButton from "../../components/buttons/likeButton";
|
||||
import { Card } from "../../components/card/card";
|
||||
|
||||
import meshBg from "../../assets/herobg.png";
|
||||
import { ArtistAlbum } from "../../components/layouts/artist/artistAlbum";
|
||||
import MusicTrack from "../../components/musicTrack";
|
||||
import { ErrorNotice } from "../../components/notices/errorNotice/errorNotice";
|
||||
import ShowMoreText from "../../components/showMoreText";
|
||||
import { useApi } from "../../utils/store/api";
|
||||
import { setBackdrop, useBackdropStore } from "../../utils/store/backdrop";
|
||||
import meshBg from "@/assets/herobg.png";
|
||||
import { ArtistAlbum } from "@/components/layouts/artist/artistAlbum";
|
||||
import MusicTrack from "@/components/musicTrack";
|
||||
import { ErrorNotice } from "@/components/notices/errorNotice/errorNotice";
|
||||
import ShowMoreText from "@/components/showMoreText";
|
||||
import { setBackdrop, useBackdropStore } from "@/utils/store/backdrop";
|
||||
import "./artist.scss";
|
||||
|
||||
import IconLink from "../../components/iconLink";
|
||||
import { getTypeIcon } from "../../components/utils/iconsCollection";
|
||||
import IconLink from "@/components/iconLink";
|
||||
import { getTypeIcon } from "@/components/utils/iconsCollection";
|
||||
import { createFileRoute } from "@tanstack/react-router";
|
||||
|
||||
function TabPanel(props) {
|
||||
const { children, value, index, ...other } = props;
|
||||
@@ -63,9 +61,13 @@ TabPanel.propTypes = {
|
||||
value: PropTypes.number.isRequired,
|
||||
};
|
||||
|
||||
const ArtistTitlePage = () => {
|
||||
const { id } = useParams();
|
||||
const [api] = useApi((state) => [state.api]);
|
||||
export const Route = createFileRoute("/_api/artist/$id")({
|
||||
component: ArtistTitlePage,
|
||||
});
|
||||
|
||||
function ArtistTitlePage() {
|
||||
const { id } = Route.useParams();
|
||||
const api = Route.useRouteContext().api;
|
||||
|
||||
const user = useQuery({
|
||||
queryKey: ["user"],
|
||||
@@ -483,6 +485,6 @@ const ArtistTitlePage = () => {
|
||||
if (item.isError) {
|
||||
return <ErrorNotice />;
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
export default ArtistTitlePage;
|
||||
File renamed without changes.
@@ -1,16 +1,14 @@
|
||||
import PropTypes from "prop-types";
|
||||
import React, { useState, useEffect, useLayoutEffect, useRef } from "react";
|
||||
import React, { useEffect, useRef } from "react";
|
||||
|
||||
import Box from "@mui/material/Box";
|
||||
import Chip from "@mui/material/Chip";
|
||||
import CircularProgress from "@mui/material/CircularProgress";
|
||||
import Divider from "@mui/material/Divider";
|
||||
import Stack from "@mui/material/Stack";
|
||||
import Typography from "@mui/material/Typography";
|
||||
import { Link, useNavigate, useParams } from "react-router-dom";
|
||||
|
||||
import useParallax from "@/utils/hooks/useParallax";
|
||||
import { motion, useScroll } from "framer-motion";
|
||||
import useParallax from "../../utils/hooks/useParallax";
|
||||
|
||||
import {
|
||||
BaseItemKind,
|
||||
@@ -23,25 +21,24 @@ import { getUserApi } from "@jellyfin/sdk/lib/utils/api/user-api";
|
||||
import { getUserLibraryApi } from "@jellyfin/sdk/lib/utils/api/user-library-api";
|
||||
import { useQuery } from "@tanstack/react-query";
|
||||
|
||||
import { Card } from "../../components/card/card";
|
||||
import { CardScroller } from "../../components/cardScroller/cardScroller";
|
||||
import Hero from "../../components/layouts/item/hero";
|
||||
import { Card } from "@/components/card/card";
|
||||
import { CardScroller } from "@/components/cardScroller/cardScroller";
|
||||
|
||||
import { ErrorNotice } from "@/components/notices/errorNotice/errorNotice";
|
||||
import ShowMoreText from "@/components/showMoreText";
|
||||
import { endsAt, getRuntime } from "@/utils/date/time";
|
||||
import { setBackdrop, useBackdropStore } from "@/utils/store/backdrop";
|
||||
import { Blurhash } from "react-blurhash";
|
||||
import { ErrorNotice } from "../../components/notices/errorNotice/errorNotice";
|
||||
import ShowMoreText from "../../components/showMoreText";
|
||||
import { endsAt, getRuntime } from "../../utils/date/time";
|
||||
import { useApi } from "../../utils/store/api";
|
||||
import { setBackdrop, useBackdropStore } from "../../utils/store/backdrop";
|
||||
|
||||
import LikeButton from "../../components/buttons/likeButton";
|
||||
import MarkPlayedButton from "../../components/buttons/markPlayedButton";
|
||||
import PlayButton from "../../components/buttons/playButton";
|
||||
import LikeButton from "@/components/buttons/likeButton";
|
||||
import MarkPlayedButton from "@/components/buttons/markPlayedButton";
|
||||
import PlayButton from "@/components/buttons/playButton";
|
||||
|
||||
import heroBg from "../../assets/herobg.png";
|
||||
import heroBg from "@/assets/herobg.png";
|
||||
import "./boxset.scss";
|
||||
|
||||
import IconLink from "../../components/iconLink";
|
||||
import IconLink from "@/components/iconLink";
|
||||
import { createFileRoute } from "@tanstack/react-router";
|
||||
|
||||
function TabPanel(props) {
|
||||
const { children, value, index, ...other } = props;
|
||||
@@ -66,9 +63,13 @@ TabPanel.propTypes = {
|
||||
value: PropTypes.number.isRequired,
|
||||
};
|
||||
|
||||
const BoxSetTitlePage = () => {
|
||||
const { id } = useParams();
|
||||
const [api] = useApi((state) => [state.api]);
|
||||
export const Route = createFileRoute("/_api/boxset/$id")({
|
||||
component: BoxSetTitlePage,
|
||||
});
|
||||
|
||||
function BoxSetTitlePage() {
|
||||
const { id } = Route.useParams();
|
||||
const api = Route.useRouteContext().api;
|
||||
|
||||
const user = useQuery({
|
||||
queryKey: ["user"],
|
||||
@@ -503,6 +504,6 @@ const BoxSetTitlePage = () => {
|
||||
if (item.isError || similarItems.isError) {
|
||||
return <ErrorNotice />;
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
export default BoxSetTitlePage;
|
||||
File renamed without changes.
@@ -14,10 +14,8 @@ import { green, red, yellow } from "@mui/material/colors";
|
||||
|
||||
import { Blurhash } from "react-blurhash";
|
||||
|
||||
import { Link, NavLink, useParams } from "react-router-dom";
|
||||
|
||||
import useParallax from "@/utils/hooks/useParallax";
|
||||
import { motion, useScroll } from "framer-motion";
|
||||
import useParallax from "../../utils/hooks/useParallax";
|
||||
|
||||
import {
|
||||
BaseItemKind,
|
||||
@@ -30,43 +28,43 @@ import { getUserLibraryApi } from "@jellyfin/sdk/lib/utils/api/user-library-api"
|
||||
|
||||
import { useQuery } from "@tanstack/react-query";
|
||||
|
||||
import heroBg from "../../assets/herobg.png";
|
||||
import { Card } from "../../components/card/card";
|
||||
import { CardScroller } from "../../components/cardScroller/cardScroller";
|
||||
import heroBg from "@/assets/herobg.png";
|
||||
import { Card } from "@/components/card/card";
|
||||
import { CardScroller } from "@/components/cardScroller/cardScroller";
|
||||
|
||||
import LikeButton from "../../components/buttons/likeButton";
|
||||
import MarkPlayedButton from "../../components/buttons/markPlayedButton";
|
||||
import PlayButton from "../../components/buttons/playButton";
|
||||
import TrailerButton from "../../components/buttons/trailerButton";
|
||||
import { ErrorNotice } from "../../components/notices/errorNotice/errorNotice";
|
||||
import ShowMoreText from "../../components/showMoreText";
|
||||
import TextLink from "../../components/textLink";
|
||||
import { getTypeIcon } from "../../components/utils/iconsCollection";
|
||||
import { endsAt, getRuntime } from "../../utils/date/time";
|
||||
import { useApi } from "../../utils/store/api";
|
||||
import { useBackdropStore } from "../../utils/store/backdrop";
|
||||
import LikeButton from "@/components/buttons/likeButton";
|
||||
import MarkPlayedButton from "@/components/buttons/markPlayedButton";
|
||||
import PlayButton from "@/components/buttons/playButton";
|
||||
import TrailerButton from "@/components/buttons/trailerButton";
|
||||
import { ErrorNotice } from "@/components/notices/errorNotice/errorNotice";
|
||||
import ShowMoreText from "@/components/showMoreText";
|
||||
import TextLink from "@/components/textLink";
|
||||
import { getTypeIcon } from "@/components/utils/iconsCollection";
|
||||
import { endsAt, getRuntime } from "@/utils/date/time";
|
||||
import { useBackdropStore } from "@/utils/store/backdrop";
|
||||
import "./episode.scss";
|
||||
|
||||
import ultraHdIcon from "../../assets/icons/4k.svg";
|
||||
import dolbyAtmosIcon from "../../assets/icons/dolby-atmos.svg";
|
||||
import dolbyDigitalPlusIcon from "../../assets/icons/dolby-digital-plus.svg";
|
||||
import dolbyDigitalIcon from "../../assets/icons/dolby-digital.svg";
|
||||
import dolbyTrueHDIcon from "../../assets/icons/dolby-truehd.svg";
|
||||
import dolbyVisionAtmosIcon from "../../assets/icons/dolby-vision-atmos.png";
|
||||
import dolbyVisionIcon from "../../assets/icons/dolby-vision.svg";
|
||||
import dtsHdMaIcon from "../../assets/icons/dts-hd-ma.svg";
|
||||
import dtsIcon from "../../assets/icons/dts.svg";
|
||||
import hdIcon from "../../assets/icons/hd.svg";
|
||||
import hdrIcon from "../../assets/icons/hdr.svg";
|
||||
import hdr10PlusIcon from "../../assets/icons/hdr10-plus.svg";
|
||||
import hdr10Icon from "../../assets/icons/hdr10.svg";
|
||||
import imaxIcon from "../../assets/icons/imax.svg";
|
||||
import sdIcon from "../../assets/icons/sd.svg";
|
||||
import sdrIcon from "../../assets/icons/sdr.svg";
|
||||
import ultraHdIcon from "@/assets/icons/4k.svg";
|
||||
import dolbyAtmosIcon from "@/assets/icons/dolby-atmos.svg";
|
||||
import dolbyDigitalPlusIcon from "@/assets/icons/dolby-digital-plus.svg";
|
||||
import dolbyDigitalIcon from "@/assets/icons/dolby-digital.svg";
|
||||
import dolbyTrueHDIcon from "@/assets/icons/dolby-truehd.svg";
|
||||
import dolbyVisionAtmosIcon from "@/assets/icons/dolby-vision-atmos.png";
|
||||
import dolbyVisionIcon from "@/assets/icons/dolby-vision.svg";
|
||||
import dtsHdMaIcon from "@/assets/icons/dts-hd-ma.svg";
|
||||
import dtsIcon from "@/assets/icons/dts.svg";
|
||||
import hdIcon from "@/assets/icons/hd.svg";
|
||||
import hdrIcon from "@/assets/icons/hdr.svg";
|
||||
import hdr10PlusIcon from "@/assets/icons/hdr10-plus.svg";
|
||||
import hdr10Icon from "@/assets/icons/hdr10.svg";
|
||||
import imaxIcon from "@/assets/icons/imax.svg";
|
||||
import sdIcon from "@/assets/icons/sd.svg";
|
||||
import sdrIcon from "@/assets/icons/sdr.svg";
|
||||
|
||||
import type MediaQualityInfo from "../../utils/types/mediaQualityInfo";
|
||||
import type MediaQualityInfo from "@/utils/types/mediaQualityInfo";
|
||||
|
||||
import IconLink from "../../components/iconLink";
|
||||
import IconLink from "@/components/iconLink";
|
||||
import { Link, createFileRoute } from "@tanstack/react-router";
|
||||
|
||||
function TabPanel(props) {
|
||||
const { children, value, index, ...other } = props;
|
||||
@@ -91,9 +89,13 @@ TabPanel.propTypes = {
|
||||
value: PropTypes.number.isRequired,
|
||||
};
|
||||
|
||||
const EpisodeTitlePage = () => {
|
||||
const { id } = useParams();
|
||||
const [api] = useApi((state) => [state.api]);
|
||||
export const Route = createFileRoute("/_api/episode/$id")({
|
||||
component: EpisodeTitlePage,
|
||||
});
|
||||
|
||||
function EpisodeTitlePage() {
|
||||
const { id } = Route.useParams();
|
||||
const api = Route.useRouteContext().api;
|
||||
|
||||
const user = useQuery({
|
||||
queryKey: ["user"],
|
||||
@@ -832,10 +834,13 @@ const EpisodeTitlePage = () => {
|
||||
<Typography variant="h6">Actors</Typography>
|
||||
<div className="item-detail-cast-grid">
|
||||
{actors.map((actor) => (
|
||||
<NavLink
|
||||
<Link
|
||||
className="item-detail-cast-card"
|
||||
key={actor.Id}
|
||||
to={`/person/${actor.Id}`}
|
||||
to={`/person/$id`}
|
||||
params={{
|
||||
id: actor.Id,
|
||||
}}
|
||||
>
|
||||
{actor.PrimaryImageTag ? (
|
||||
<img
|
||||
@@ -865,7 +870,7 @@ const EpisodeTitlePage = () => {
|
||||
{actor.Role}
|
||||
</Typography>
|
||||
</div>
|
||||
</NavLink>
|
||||
</Link>
|
||||
))}
|
||||
</div>
|
||||
</div>
|
||||
@@ -875,10 +880,13 @@ const EpisodeTitlePage = () => {
|
||||
<Typography variant="h6">Writers</Typography>
|
||||
<div className="item-detail-cast-grid">
|
||||
{writers.map((actor) => (
|
||||
<NavLink
|
||||
<Link
|
||||
className="item-detail-cast-card"
|
||||
key={actor.Id}
|
||||
to={`/person/${actor.Id}`}
|
||||
to={`/person/$id`}
|
||||
params={{
|
||||
id: actor.Id,
|
||||
}}
|
||||
>
|
||||
{actor.PrimaryImageTag ? (
|
||||
<img
|
||||
@@ -908,7 +916,7 @@ const EpisodeTitlePage = () => {
|
||||
{actor.Role}
|
||||
</Typography>
|
||||
</div>
|
||||
</NavLink>
|
||||
</Link>
|
||||
))}
|
||||
</div>
|
||||
</div>
|
||||
@@ -918,10 +926,13 @@ const EpisodeTitlePage = () => {
|
||||
<Typography variant="h6">Directors</Typography>
|
||||
<div className="item-detail-cast-grid">
|
||||
{directors.map((actor) => (
|
||||
<NavLink
|
||||
<Link
|
||||
className="item-detail-cast-card"
|
||||
to={`/person/${actor.Id}`}
|
||||
key={actor.Id}
|
||||
to={`/person/$id`}
|
||||
params={{
|
||||
id: actor.Id,
|
||||
}}
|
||||
>
|
||||
{actor.PrimaryImageTag ? (
|
||||
<img
|
||||
@@ -951,7 +962,7 @@ const EpisodeTitlePage = () => {
|
||||
{actor.Role}
|
||||
</Typography>
|
||||
</div>
|
||||
</NavLink>
|
||||
</Link>
|
||||
))}
|
||||
</div>
|
||||
</div>
|
||||
@@ -961,10 +972,13 @@ const EpisodeTitlePage = () => {
|
||||
<Typography variant="h6">Producers</Typography>
|
||||
<div className="item-detail-cast-grid">
|
||||
{producers.map((actor) => (
|
||||
<NavLink
|
||||
<Link
|
||||
className="item-detail-cast-card"
|
||||
key={actor.Id}
|
||||
to={`/person/${actor.Id}`}
|
||||
to={`/person/$id`}
|
||||
params={{
|
||||
id: actor.Id,
|
||||
}}
|
||||
>
|
||||
{actor.PrimaryImageTag ? (
|
||||
<img
|
||||
@@ -994,7 +1008,7 @@ const EpisodeTitlePage = () => {
|
||||
{actor.Role}
|
||||
</Typography>
|
||||
</div>
|
||||
</NavLink>
|
||||
</Link>
|
||||
))}
|
||||
</div>
|
||||
</div>
|
||||
@@ -1007,6 +1021,6 @@ const EpisodeTitlePage = () => {
|
||||
if (item.isError) {
|
||||
return <ErrorNotice />;
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
export default EpisodeTitlePage;
|
||||
File renamed without changes.
File renamed without changes.
@@ -1,20 +1,24 @@
|
||||
import React, { useEffect } from "react";
|
||||
|
||||
import { useBackdropStore } from "../../utils/store/backdrop";
|
||||
import { useBackdropStore } from "@/utils/store/backdrop";
|
||||
|
||||
import Typography from "@mui/material/Typography";
|
||||
import { useQuery } from "@tanstack/react-query";
|
||||
import "./favorite.scss";
|
||||
|
||||
import { Card } from "@/components/card/card";
|
||||
import { CardScroller } from "@/components/cardScroller/cardScroller";
|
||||
import { BaseItemKind } from "@jellyfin/sdk/lib/generated-client";
|
||||
import { getItemsApi } from "@jellyfin/sdk/lib/utils/api/items-api";
|
||||
import { getUserApi } from "@jellyfin/sdk/lib/utils/api/user-api";
|
||||
import { Card } from "../../components/card/card";
|
||||
import { CardScroller } from "../../components/cardScroller/cardScroller";
|
||||
import { useApi } from "../../utils/store/api";
|
||||
import { createFileRoute } from "@tanstack/react-router";
|
||||
|
||||
const FavoritePage = () => {
|
||||
const [api] = useApi((state) => [state.api]);
|
||||
export const Route = createFileRoute("/_api/favorite/")({
|
||||
component: FavoritePage,
|
||||
});
|
||||
|
||||
function FavoritePage() {
|
||||
const api = Route.useRouteContext().api;
|
||||
const [setBackdrop] = useBackdropStore((state) => [state.setBackdrop]);
|
||||
|
||||
const user = useQuery({
|
||||
@@ -167,7 +171,7 @@ const FavoritePage = () => {
|
||||
item.EndDate
|
||||
? new Date(item.EndDate).toLocaleString([], {
|
||||
year: "numeric",
|
||||
})
|
||||
})
|
||||
: "Present"
|
||||
}`}
|
||||
cardType="portrait"
|
||||
@@ -297,6 +301,6 @@ const FavoritePage = () => {
|
||||
)}
|
||||
</main>
|
||||
);
|
||||
};
|
||||
}
|
||||
|
||||
export default FavoritePage;
|
||||
File renamed without changes.
@@ -4,14 +4,14 @@ import { useQuery } from "@tanstack/react-query";
|
||||
|
||||
import "./home.scss";
|
||||
|
||||
import Carousel from "../../components/carousel";
|
||||
import Carousel from "@/components/carousel";
|
||||
|
||||
// Custom Components
|
||||
import { Card } from "../../components/card/card";
|
||||
import { CardScroller } from "../../components/cardScroller/cardScroller";
|
||||
import { LatestMediaSection } from "../../components/layouts/homeSection/latestMediaSection";
|
||||
import { CardsSkeleton } from "../../components/skeleton/cards";
|
||||
import { CarouselSkeleton } from "../../components/skeleton/carousel";
|
||||
import { Card } from "@/components/card/card";
|
||||
import { CardScroller } from "@/components/cardScroller/cardScroller";
|
||||
import { LatestMediaSection } from "@/components/layouts/homeSection/latestMediaSection";
|
||||
import { CardsSkeleton } from "@/components/skeleton/cards";
|
||||
import { CarouselSkeleton } from "@/components/skeleton/carousel";
|
||||
|
||||
import { getItemsApi } from "@jellyfin/sdk/lib/utils/api/items-api";
|
||||
import { getTvShowsApi } from "@jellyfin/sdk/lib/utils/api/tv-shows-api";
|
||||
@@ -19,20 +19,23 @@ import { getUserApi } from "@jellyfin/sdk/lib/utils/api/user-api";
|
||||
import { getUserLibraryApi } from "@jellyfin/sdk/lib/utils/api/user-library-api";
|
||||
import { getUserViewsApi } from "@jellyfin/sdk/lib/utils/api/user-views-api";
|
||||
|
||||
import { useNavigate } from "react-router-dom";
|
||||
import { createFileRoute, useNavigate } from "@tanstack/react-router";
|
||||
|
||||
import { setBackdrop, useBackdropStore } from "../../utils/store/backdrop";
|
||||
import { setBackdrop, useBackdropStore } from "@/utils/store/backdrop";
|
||||
|
||||
import CarouselSlide from "@/components/carouselSlide";
|
||||
import { ErrorNotice } from "@/components/notices/errorNotice/errorNotice";
|
||||
import { BaseItemKind, ItemFields } from "@jellyfin/sdk/lib/generated-client";
|
||||
import Typography from "@mui/material/Typography";
|
||||
import { useSnackbar } from "notistack";
|
||||
import { ErrorBoundary } from "react-error-boundary";
|
||||
import CarouselSlide from "../../components/carouselSlide";
|
||||
import { ErrorNotice } from "../../components/notices/errorNotice/errorNotice";
|
||||
import { useApi } from "../../utils/store/api";
|
||||
|
||||
const Home = () => {
|
||||
const [api] = useApi((state) => [state.api]);
|
||||
export const Route = createFileRoute("/_api/home/")({
|
||||
component: Home,
|
||||
});
|
||||
|
||||
function Home() {
|
||||
const api = Route.useRouteContext().api;
|
||||
|
||||
const user = useQuery({
|
||||
queryKey: ["user"],
|
||||
@@ -91,7 +94,7 @@ const Home = () => {
|
||||
return resumeItems.data;
|
||||
},
|
||||
enabled: !!user.data,
|
||||
refetchOnMount: true
|
||||
refetchOnMount: true,
|
||||
});
|
||||
|
||||
const resumeItemsAudio = useQuery({
|
||||
@@ -127,7 +130,7 @@ const Home = () => {
|
||||
return upNext.data;
|
||||
},
|
||||
enabled: !!user.data,
|
||||
refetchOnMount: true
|
||||
refetchOnMount: true,
|
||||
});
|
||||
|
||||
const [latestMediaLibs, setLatestMediaLibs] = useState([]);
|
||||
@@ -221,7 +224,7 @@ const Home = () => {
|
||||
imageType="Primary"
|
||||
cardType="thumb"
|
||||
disableOverlay
|
||||
onClick={() => navigate(`/library/${item.Id}`)}
|
||||
onClick={() => navigate({ to: `/library/${item.Id}` })}
|
||||
imageBlurhash={
|
||||
!!item.ImageBlurHashes?.Primary &&
|
||||
item.ImageBlurHashes?.Primary[
|
||||
@@ -412,6 +415,6 @@ const Home = () => {
|
||||
</main>
|
||||
</>
|
||||
);
|
||||
};
|
||||
}
|
||||
|
||||
export default React.memo(Home);
|
||||
@@ -14,10 +14,8 @@ import { green, red, yellow } from "@mui/material/colors";
|
||||
|
||||
import { Blurhash } from "react-blurhash";
|
||||
|
||||
import { Link, NavLink, useParams } from "react-router-dom";
|
||||
|
||||
import useParallax from "@/utils/hooks/useParallax";
|
||||
import { motion, useScroll } from "framer-motion";
|
||||
import useParallax from "../../utils/hooks/useParallax";
|
||||
|
||||
import {
|
||||
BaseItemKind,
|
||||
@@ -30,47 +28,46 @@ import { getUserLibraryApi } from "@jellyfin/sdk/lib/utils/api/user-library-api"
|
||||
|
||||
import { useQuery } from "@tanstack/react-query";
|
||||
|
||||
import heroBg from "../../assets/herobg.png";
|
||||
import { Card } from "../../components/card/card";
|
||||
import { CardScroller } from "../../components/cardScroller/cardScroller";
|
||||
import heroBg from "@/assets/herobg.png";
|
||||
import { Card } from "@/components/card/card";
|
||||
import { CardScroller } from "@/components/cardScroller/cardScroller";
|
||||
|
||||
import "./item.scss";
|
||||
|
||||
import { ErrorNotice } from "../../components/notices/errorNotice/errorNotice";
|
||||
import { ErrorNotice } from "@/components/notices/errorNotice/errorNotice";
|
||||
|
||||
import LikeButton from "../../components/buttons/likeButton";
|
||||
import MarkPlayedButton from "../../components/buttons/markPlayedButton";
|
||||
import PlayButton from "../../components/buttons/playButton";
|
||||
import TrailerButton from "../../components/buttons/trailerButton";
|
||||
import ShowMoreText from "../../components/showMoreText";
|
||||
import TextLink from "../../components/textLink";
|
||||
import { getTypeIcon } from "../../components/utils/iconsCollection";
|
||||
import { endsAt, getRuntime } from "../../utils/date/time";
|
||||
import { useApi } from "../../utils/store/api";
|
||||
import { setBackdrop, useBackdropStore } from "../../utils/store/backdrop";
|
||||
import LikeButton from "@/components/buttons/likeButton";
|
||||
import MarkPlayedButton from "@/components/buttons/markPlayedButton";
|
||||
import PlayButton from "@/components/buttons/playButton";
|
||||
import TrailerButton from "@/components/buttons/trailerButton";
|
||||
import ShowMoreText from "@/components/showMoreText";
|
||||
import { getTypeIcon } from "@/components/utils/iconsCollection";
|
||||
import { endsAt, getRuntime } from "@/utils/date/time";
|
||||
import { setBackdrop, useBackdropStore } from "@/utils/store/backdrop";
|
||||
|
||||
import ItemSkeleton from "../../components/skeleton/item";
|
||||
import ItemSkeleton from "@/components/skeleton/item";
|
||||
|
||||
import ultraHdIcon from "../../assets/icons/4k.svg";
|
||||
import dolbyAtmosIcon from "../../assets/icons/dolby-atmos.svg";
|
||||
import dolbyDigitalPlusIcon from "../../assets/icons/dolby-digital-plus.svg";
|
||||
import dolbyDigitalIcon from "../../assets/icons/dolby-digital.svg";
|
||||
import dolbyTrueHDIcon from "../../assets/icons/dolby-truehd.svg";
|
||||
import dolbyVisionAtmosIcon from "../../assets/icons/dolby-vision-atmos.png";
|
||||
import dolbyVisionIcon from "../../assets/icons/dolby-vision.svg";
|
||||
import dtsHdMaIcon from "../../assets/icons/dts-hd-ma.svg";
|
||||
import dtsIcon from "../../assets/icons/dts.svg";
|
||||
import hdIcon from "../../assets/icons/hd.svg";
|
||||
import hdrIcon from "../../assets/icons/hdr.svg";
|
||||
import hdr10PlusIcon from "../../assets/icons/hdr10-plus.svg";
|
||||
import hdr10Icon from "../../assets/icons/hdr10.svg";
|
||||
import imaxIcon from "../../assets/icons/imax.svg";
|
||||
import sdIcon from "../../assets/icons/sd.svg";
|
||||
import sdrIcon from "../../assets/icons/sdr.svg";
|
||||
import ultraHdIcon from "@/assets/icons/4k.svg";
|
||||
import dolbyAtmosIcon from "@/assets/icons/dolby-atmos.svg";
|
||||
import dolbyDigitalPlusIcon from "@/assets/icons/dolby-digital-plus.svg";
|
||||
import dolbyDigitalIcon from "@/assets/icons/dolby-digital.svg";
|
||||
import dolbyTrueHDIcon from "@/assets/icons/dolby-truehd.svg";
|
||||
import dolbyVisionAtmosIcon from "@/assets/icons/dolby-vision-atmos.png";
|
||||
import dolbyVisionIcon from "@/assets/icons/dolby-vision.svg";
|
||||
import dtsHdMaIcon from "@/assets/icons/dts-hd-ma.svg";
|
||||
import dtsIcon from "@/assets/icons/dts.svg";
|
||||
import hdIcon from "@/assets/icons/hd.svg";
|
||||
import hdrIcon from "@/assets/icons/hdr.svg";
|
||||
import hdr10PlusIcon from "@/assets/icons/hdr10-plus.svg";
|
||||
import hdr10Icon from "@/assets/icons/hdr10.svg";
|
||||
import imaxIcon from "@/assets/icons/imax.svg";
|
||||
import sdIcon from "@/assets/icons/sd.svg";
|
||||
import sdrIcon from "@/assets/icons/sdr.svg";
|
||||
|
||||
import type MediaQualityInfo from "../../utils/types/mediaQualityInfo";
|
||||
import type MediaQualityInfo from "@/utils/types/mediaQualityInfo";
|
||||
|
||||
import IconLink from "../../components/iconLink";
|
||||
import IconLink from "@/components/iconLink";
|
||||
import { Link, createFileRoute } from "@tanstack/react-router";
|
||||
|
||||
function TabPanel(props) {
|
||||
const { children, value, index, ...other } = props;
|
||||
@@ -95,10 +92,14 @@ TabPanel.propTypes = {
|
||||
value: PropTypes.number.isRequired,
|
||||
};
|
||||
|
||||
const ItemDetail = () => {
|
||||
const { id } = useParams();
|
||||
export const Route = createFileRoute("/_api/item/$id")({
|
||||
component: ItemDetail,
|
||||
});
|
||||
|
||||
const [api] = useApi((state) => [state.api]);
|
||||
function ItemDetail() {
|
||||
const { id } = Route.useParams();
|
||||
|
||||
const api = Route.useRouteContext().api;
|
||||
|
||||
const user = useQuery({
|
||||
queryKey: ["user"],
|
||||
@@ -824,10 +825,13 @@ const ItemDetail = () => {
|
||||
<Typography variant="h6">Actors</Typography>
|
||||
<div className="item-detail-cast-grid">
|
||||
{actors.map((actor) => (
|
||||
<NavLink
|
||||
<Link
|
||||
className="item-detail-cast-card"
|
||||
key={actor.Id}
|
||||
to={`/person/${actor.Id}`}
|
||||
to="/person/$id"
|
||||
params={{
|
||||
id: actor.Id,
|
||||
}}
|
||||
>
|
||||
{actor.PrimaryImageTag ? (
|
||||
<img
|
||||
@@ -857,7 +861,7 @@ const ItemDetail = () => {
|
||||
{actor.Role}
|
||||
</Typography>
|
||||
</div>
|
||||
</NavLink>
|
||||
</Link>
|
||||
))}
|
||||
</div>
|
||||
</div>
|
||||
@@ -867,7 +871,7 @@ const ItemDetail = () => {
|
||||
<Typography variant="h6">Writers</Typography>
|
||||
<div className="item-detail-cast-grid">
|
||||
{writers.map((actor) => (
|
||||
<NavLink
|
||||
<Link
|
||||
className="item-detail-cast-card"
|
||||
key={actor.Id}
|
||||
to={`/person/${actor.Id}`}
|
||||
@@ -900,7 +904,7 @@ const ItemDetail = () => {
|
||||
{actor.Role}
|
||||
</Typography>
|
||||
</div>
|
||||
</NavLink>
|
||||
</Link>
|
||||
))}
|
||||
</div>
|
||||
</div>
|
||||
@@ -910,10 +914,13 @@ const ItemDetail = () => {
|
||||
<Typography variant="h6">Directors</Typography>
|
||||
<div className="item-detail-cast-grid">
|
||||
{directors.map((actor) => (
|
||||
<NavLink
|
||||
<Link
|
||||
className="item-detail-cast-card"
|
||||
to={`/person/${actor.Id}`}
|
||||
to="/person/$id"
|
||||
key={actor.Id}
|
||||
params={{
|
||||
id: actor.Id,
|
||||
}}
|
||||
>
|
||||
{actor.PrimaryImageTag ? (
|
||||
<img
|
||||
@@ -943,7 +950,7 @@ const ItemDetail = () => {
|
||||
{actor.Role}
|
||||
</Typography>
|
||||
</div>
|
||||
</NavLink>
|
||||
</Link>
|
||||
))}
|
||||
</div>
|
||||
</div>
|
||||
@@ -953,10 +960,13 @@ const ItemDetail = () => {
|
||||
<Typography variant="h6">Producers</Typography>
|
||||
<div className="item-detail-cast-grid">
|
||||
{producers.map((actor) => (
|
||||
<NavLink
|
||||
<Link
|
||||
className="item-detail-cast-card"
|
||||
key={actor.Id}
|
||||
to={`/person/${actor.Id}`}
|
||||
to={`/person/$id`}
|
||||
params={{
|
||||
id: actor.Id,
|
||||
}}
|
||||
>
|
||||
{actor.PrimaryImageTag ? (
|
||||
<img
|
||||
@@ -986,7 +996,7 @@ const ItemDetail = () => {
|
||||
{actor.Role}
|
||||
</Typography>
|
||||
</div>
|
||||
</NavLink>
|
||||
</Link>
|
||||
))}
|
||||
</div>
|
||||
</div>
|
||||
@@ -1049,6 +1059,6 @@ const ItemDetail = () => {
|
||||
if (item.isError || similarItems.isError) {
|
||||
return <ErrorNotice />;
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
export default ItemDetail;
|
||||
File renamed without changes.
@@ -1,8 +1,7 @@
|
||||
import { motion } from "framer-motion";
|
||||
import React, { useState, useEffect, useLayoutEffect } from "react";
|
||||
import { useParams } from "react-router-dom";
|
||||
|
||||
import { useInfiniteQuery, useQuery } from "@tanstack/react-query";
|
||||
import { useQuery } from "@tanstack/react-query";
|
||||
|
||||
import Accordion from "@mui/material/Accordion";
|
||||
import AccordionDetails from "@mui/material/AccordionDetails";
|
||||
@@ -31,27 +30,26 @@ import { getPersonsApi } from "@jellyfin/sdk/lib/utils/api/persons-api";
|
||||
import { getStudiosApi } from "@jellyfin/sdk/lib/utils/api/studios-api";
|
||||
import { getUserApi } from "@jellyfin/sdk/lib/utils/api/user-api";
|
||||
|
||||
import { Card } from "../../components/card/card";
|
||||
import { EmptyNotice } from "../../components/notices/emptyNotice/emptyNotice";
|
||||
import { Card } from "@/components/card/card";
|
||||
import { EmptyNotice } from "@/components/notices/emptyNotice/emptyNotice";
|
||||
|
||||
import GenreView from "@/components/layouts/library/genreView";
|
||||
import MusicTrack from "@/components/musicTrack";
|
||||
import { ErrorNotice } from "@/components/notices/errorNotice/errorNotice";
|
||||
import { setBackdrop, useBackdropStore } from "@/utils/store/backdrop";
|
||||
import {
|
||||
type BaseItemDtoQueryResult,
|
||||
BaseItemKind,
|
||||
ItemFields,
|
||||
SortOrder,
|
||||
} from "@jellyfin/sdk/lib/generated-client";
|
||||
import GenreView from "../../components/layouts/library/genreView";
|
||||
import MusicTrack from "../../components/musicTrack";
|
||||
import { ErrorNotice } from "../../components/notices/errorNotice/errorNotice";
|
||||
import { setBackdrop, useBackdropStore } from "../../utils/store/backdrop";
|
||||
|
||||
import { getUserLibraryApi } from "@jellyfin/sdk/lib/utils/api/user-library-api";
|
||||
import { useScrollTrigger } from "@mui/material";
|
||||
import { useVirtualizer, useWindowVirtualizer } from "@tanstack/react-virtual";
|
||||
import { useWindowVirtualizer } from "@tanstack/react-virtual";
|
||||
import type { AxiosResponse } from "axios";
|
||||
import { enqueueSnackbar } from "notistack";
|
||||
import { useApi } from "../../utils/store/api";
|
||||
import "./library.scss";
|
||||
import { createFileRoute } from "@tanstack/react-router";
|
||||
|
||||
const useWindowWidth = () => {
|
||||
const [width, setWidth] = React.useState(window.innerWidth);
|
||||
@@ -72,11 +70,14 @@ const useWindowWidth = () => {
|
||||
return width;
|
||||
};
|
||||
|
||||
const LibraryView = () => {
|
||||
const [api] = useApi((state) => [state.api]);
|
||||
const maxDisplayItems = 100;
|
||||
export const Route = createFileRoute("/_api/library/$id")({
|
||||
component: LibraryView,
|
||||
});
|
||||
|
||||
const { id } = useParams();
|
||||
function LibraryView() {
|
||||
const api = Route.useRouteContext().api;
|
||||
|
||||
const { id } = Route.useParams();
|
||||
|
||||
const user = useQuery({
|
||||
queryKey: ["user"],
|
||||
@@ -370,6 +371,14 @@ const LibraryView = () => {
|
||||
const backdropItemsTemp = items.data.Items?.filter(
|
||||
(item) => item.BackdropImageTags?.length > 0,
|
||||
);
|
||||
const backdropItem = backdropItemsTemp[0];
|
||||
// enqueueSnackbar("Running");
|
||||
setBackdrop(
|
||||
api?.getItemImageUrl(backdropItem?.Id, "Backdrop", {
|
||||
tag: backdropItem?.BackdropImageTags[0],
|
||||
}),
|
||||
backdropItem?.BackdropImageTags[0] ?? "none",
|
||||
);
|
||||
setBackdropItems(backdropItemsTemp);
|
||||
}
|
||||
}, [items.isSuccess]);
|
||||
@@ -384,7 +393,7 @@ const LibraryView = () => {
|
||||
api?.getItemImageUrl(backdropItem.Id, "Backdrop", {
|
||||
tag: backdropItem.BackdropImageTags[0],
|
||||
}),
|
||||
backdropItem.Id,
|
||||
backdropItem.BackdropImageTags[0] ?? "none",
|
||||
);
|
||||
}, 10000); // Update backdrop every 10s
|
||||
return () => clearInterval(intervalId);
|
||||
@@ -1333,6 +1342,6 @@ const LibraryView = () => {
|
||||
if (currentLib.isError) {
|
||||
return <h6>{currentLib.error}</h6>;
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
export default LibraryView;
|
||||
File renamed without changes.
@@ -0,0 +1,211 @@
|
||||
import LoadingButton from "@mui/lab/LoadingButton";
|
||||
import { OutlinedInput, Paper, Typography } from "@mui/material";
|
||||
import Checkbox from "@mui/material/Checkbox";
|
||||
import FormControl from "@mui/material/FormControl";
|
||||
import FormControlLabel from "@mui/material/FormControlLabel";
|
||||
import FormGroup from "@mui/material/FormGroup";
|
||||
import IconButton from "@mui/material/IconButton";
|
||||
import InputAdornment from "@mui/material/InputAdornment";
|
||||
import InputLabel from "@mui/material/InputLabel";
|
||||
|
||||
import { useSnackbar } from "notistack";
|
||||
|
||||
import { AppBarBackOnly } from "@/components/appBar/backOnly.jsx";
|
||||
import { AvatarImage } from "@/components/avatar/avatar.jsx";
|
||||
import { createApi } from "@/utils/store/api.js";
|
||||
import "./login.scss";
|
||||
|
||||
import { saveUser } from "@/utils/storage/user";
|
||||
import { setBackdrop } from "@/utils/store/backdrop.js";
|
||||
import { createFileRoute, useNavigate } from "@tanstack/react-router";
|
||||
import React, { useLayoutEffect, useState } from "react";
|
||||
|
||||
export const Route = createFileRoute("/_api/login/$userId/$userName")({
|
||||
component: LoginUser,
|
||||
});
|
||||
|
||||
function LoginUser() {
|
||||
const { userName, userId } = Route.useParams();
|
||||
|
||||
const api = Route.useRouteContext().api;
|
||||
|
||||
const [password, setPassword] = useState({
|
||||
showpass: false,
|
||||
});
|
||||
const [loading, setLoading] = useState(false);
|
||||
const [rememberMe, setRememberMe] = useState(true);
|
||||
|
||||
const navigate = useNavigate({ from: "/login/$userId/$userName" });
|
||||
|
||||
const { enqueueSnackbar } = useSnackbar();
|
||||
|
||||
const handlePassword = (prop) => (event) => {
|
||||
setPassword({
|
||||
...password,
|
||||
[prop]: event.target.value,
|
||||
});
|
||||
};
|
||||
|
||||
const handleShowPassword = () => {
|
||||
setPassword({
|
||||
...password,
|
||||
showpass: !password.showpass,
|
||||
});
|
||||
};
|
||||
|
||||
const authUser = async () => {
|
||||
try {
|
||||
const auth = await api.authenticateUserByName(
|
||||
userName,
|
||||
password.password,
|
||||
);
|
||||
return auth;
|
||||
} catch (error) {
|
||||
if (error.response?.status === 500) {
|
||||
enqueueSnackbar(
|
||||
"Unable to connect to server. Please try again after some time.",
|
||||
{ variant: "error" },
|
||||
);
|
||||
} else {
|
||||
enqueueSnackbar("Incorrect Password.", { variant: "error" });
|
||||
}
|
||||
setLoading(false);
|
||||
console.error(error);
|
||||
}
|
||||
};
|
||||
|
||||
const handleLogin = async () => {
|
||||
setLoading(true);
|
||||
const user = await authUser();
|
||||
sessionStorage.setItem("accessToken", user.data.AccessToken);
|
||||
createApi(api.basePath, user.data.AccessToken);
|
||||
if (rememberMe === true) {
|
||||
await saveUser(userName, user.data.AccessToken);
|
||||
}
|
||||
setLoading(false);
|
||||
navigate("/home");
|
||||
};
|
||||
|
||||
useLayoutEffect(() => {
|
||||
setBackdrop("", "");
|
||||
}, []);
|
||||
|
||||
const handleCheckRememberMe = (event) => {
|
||||
setRememberMe(event.target.checked);
|
||||
};
|
||||
|
||||
return (
|
||||
<>
|
||||
<AppBarBackOnly />
|
||||
<div
|
||||
style={{
|
||||
height: "100vh",
|
||||
display: "flex",
|
||||
justifyContent: "center",
|
||||
alignItems: "center",
|
||||
flexDirection: "column",
|
||||
width: "30vw",
|
||||
margin: "auto",
|
||||
}}
|
||||
>
|
||||
<div
|
||||
style={{
|
||||
marginBottom: "-4em",
|
||||
boxShadow: "1em 0 hsl(256, 100%, 6%)",
|
||||
}}
|
||||
>
|
||||
<AvatarImage userId={userId} />
|
||||
</div>
|
||||
<Paper
|
||||
sx={{
|
||||
width: "100%",
|
||||
padding: "1em",
|
||||
paddingTop: "5em",
|
||||
borderRadius: "10px",
|
||||
}}
|
||||
elevation={2}
|
||||
>
|
||||
<Typography
|
||||
textAlign="center"
|
||||
variant="h5"
|
||||
sx={{ opacity: 0.8 }}
|
||||
mb={2}
|
||||
>
|
||||
Login as{" "}
|
||||
<Typography
|
||||
variant="h5"
|
||||
style={{
|
||||
display: "inline",
|
||||
}}
|
||||
fontWeight={700}
|
||||
className="gradient-text"
|
||||
>
|
||||
{userName}
|
||||
</Typography>
|
||||
</Typography>
|
||||
<FormGroup
|
||||
sx={{
|
||||
width: "100%",
|
||||
}}
|
||||
>
|
||||
<FormControl
|
||||
variant="outlined"
|
||||
style={{
|
||||
width: "100%",
|
||||
}}
|
||||
>
|
||||
<InputLabel htmlFor="user-password">Password:</InputLabel>
|
||||
<OutlinedInput
|
||||
id="user-password"
|
||||
type={password.showpass ? "text" : "password"}
|
||||
variant="outlined"
|
||||
onChange={handlePassword("password")}
|
||||
label="Password:"
|
||||
endAdornment={
|
||||
<InputAdornment position="end">
|
||||
<IconButton
|
||||
onClick={handleShowPassword}
|
||||
aria-label="toggle password visibility"
|
||||
>
|
||||
{password.showpass ? (
|
||||
<span className="material-symbols-rounded">
|
||||
visibility
|
||||
</span>
|
||||
) : (
|
||||
<span className="material-symbols-rounded">
|
||||
visibility_off
|
||||
</span>
|
||||
)}
|
||||
</IconButton>
|
||||
</InputAdornment>
|
||||
}
|
||||
/>
|
||||
</FormControl>
|
||||
<FormControlLabel
|
||||
control={
|
||||
<Checkbox
|
||||
checked={rememberMe}
|
||||
onChange={handleCheckRememberMe}
|
||||
/>
|
||||
}
|
||||
label="Remember me"
|
||||
/>
|
||||
</FormGroup>
|
||||
<LoadingButton
|
||||
variant="contained"
|
||||
endIcon={
|
||||
<span className="material-symbols-rounded">chevron_right</span>
|
||||
}
|
||||
onClick={handleLogin}
|
||||
loading={loading}
|
||||
loadingPosition="end"
|
||||
size="large"
|
||||
fullWidth
|
||||
>
|
||||
Login
|
||||
</LoadingButton>
|
||||
</Paper>
|
||||
</div>
|
||||
</>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,91 @@
|
||||
import { getUserApi } from "@jellyfin/sdk/lib/utils/api/user-api";
|
||||
import { Typography } from "@mui/material";
|
||||
import CircularProgress from "@mui/material/CircularProgress";
|
||||
import { useQuery } from "@tanstack/react-query";
|
||||
import { useLocation, useNavigate } from "@tanstack/react-router";
|
||||
import React, { Suspense, useState } from "react";
|
||||
|
||||
import "./login.scss";
|
||||
|
||||
import { createFileRoute } from "@tanstack/react-router";
|
||||
import { AnimatePresence, motion } from "framer-motion";
|
||||
import Markdown from "react-markdown";
|
||||
import remarkGfm from "remark-gfm";
|
||||
|
||||
export const Route = createFileRoute("/_api/login/")({
|
||||
component: LoginRoute,
|
||||
});
|
||||
|
||||
function LoginRoute() {
|
||||
const location = useLocation();
|
||||
const navigate = useNavigate();
|
||||
const api = Route.useRouteContext().api;
|
||||
const [status, setStatus] = useState("Fetching public users...");
|
||||
|
||||
const usersList = useQuery({
|
||||
queryKey: ["public-users"],
|
||||
queryFn: async () => {
|
||||
const result = await getUserApi(api).getPublicUsers();
|
||||
return result.data;
|
||||
},
|
||||
enabled: Boolean(api),
|
||||
});
|
||||
|
||||
if (location.pathname === "/login") {
|
||||
console.log(api);
|
||||
if (usersList.isSuccess && !usersList.isFetching) {
|
||||
if (usersList.data.length > 0) {
|
||||
setStatus("Public users found!");
|
||||
navigate({ to: "/login/list" });
|
||||
} else {
|
||||
setStatus("No public users found");
|
||||
navigate({ to: "/login/manual" });
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return (
|
||||
<Suspense fallback={<h1>Loading /login</h1>}>
|
||||
<div
|
||||
style={{
|
||||
position: "relative",
|
||||
display: "flex",
|
||||
alignItems: "center",
|
||||
justifyContent: "center",
|
||||
flexDirection: "column",
|
||||
width: "100vw",
|
||||
height: "100vh",
|
||||
}}
|
||||
>
|
||||
<CircularProgress size={72} thickness={2} />
|
||||
<AnimatePresence mode="wait">
|
||||
<motion.div
|
||||
key={status}
|
||||
initial={{
|
||||
opacity: 0,
|
||||
transform: "translateY(10px)",
|
||||
}}
|
||||
layout
|
||||
animate={{ opacity: 1, transform: "translateY(0px)" }}
|
||||
exit={{
|
||||
opacity: 0,
|
||||
transform: "translateY(-10px)",
|
||||
}}
|
||||
>
|
||||
<Typography
|
||||
component={Markdown}
|
||||
remarkPlugins={[remarkGfm]}
|
||||
color="white"
|
||||
variant="h6"
|
||||
mt={3}
|
||||
fontWeight={350}
|
||||
textAlign="center"
|
||||
>
|
||||
{status}
|
||||
</Typography>
|
||||
</motion.div>
|
||||
</AnimatePresence>
|
||||
</div>
|
||||
</Suspense>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,342 @@
|
||||
import { EventEmitter as event } from "@/eventEmitter.js";
|
||||
import { useMutation, useQuery } from "@tanstack/react-query";
|
||||
import React, { useLayoutEffect, useState } from "react";
|
||||
|
||||
import { saveUser } from "@/utils/storage/user.js";
|
||||
|
||||
import LoadingButton from "@mui/lab/LoadingButton";
|
||||
import {
|
||||
Dialog,
|
||||
DialogActions,
|
||||
DialogContent,
|
||||
DialogContentText,
|
||||
Grid,
|
||||
OutlinedInput,
|
||||
Paper,
|
||||
Tooltip,
|
||||
Typography,
|
||||
} from "@mui/material";
|
||||
import Button from "@mui/material/Button";
|
||||
import Checkbox from "@mui/material/Checkbox";
|
||||
import Container from "@mui/material/Container";
|
||||
import FormControlLabel from "@mui/material/FormControlLabel";
|
||||
import LinearProgress from "@mui/material/LinearProgress";
|
||||
|
||||
import { useSnackbar } from "notistack";
|
||||
|
||||
import { AppBarBackOnly } from "@/components/appBar/backOnly.jsx";
|
||||
import { Card } from "@/components/card/card.js";
|
||||
|
||||
import { getQuickConnectApi } from "@jellyfin/sdk/lib/utils/api/quick-connect-api";
|
||||
import { getUserApi } from "@jellyfin/sdk/lib/utils/api/user-api";
|
||||
|
||||
import { ErrorNotice } from "@/components/notices/errorNotice/errorNotice.jsx";
|
||||
import { createApi } from "@/utils/store/api.js";
|
||||
import "./login.scss";
|
||||
|
||||
import { setBackdrop } from "@/utils/store/backdrop.js";
|
||||
import { blue } from "@mui/material/colors";
|
||||
import { createFileRoute, useNavigate } from "@tanstack/react-router";
|
||||
|
||||
export const Route = createFileRoute("/_api/login/list")({
|
||||
component: LoginPublicUsersList,
|
||||
loader: async ({context}) => {
|
||||
const api = context.api;
|
||||
const result = await getUserApi(api).getPublicUsers();
|
||||
return result.data;
|
||||
},
|
||||
});
|
||||
|
||||
function LoginPublicUsersList() {
|
||||
const navigate = useNavigate();
|
||||
|
||||
const { enqueueSnackbar } = useSnackbar();
|
||||
|
||||
const api = Route.useRouteContext().api;
|
||||
|
||||
const [loading, setLoading] = useState(false);
|
||||
const [rememberMe, setRememberMe] = useState(true);
|
||||
const [quickConnectLoading, setQuickConnectLoading] = useState(-1);
|
||||
const [quickConnectCode, setQuickConnectCode] = useState("");
|
||||
|
||||
const handleCheckRememberMe = (event) => {
|
||||
setRememberMe(event.target.checked);
|
||||
};
|
||||
|
||||
const handleChangeServer = () => {
|
||||
// navigate("/servers/list");
|
||||
};
|
||||
const handleManualLogin = () => {
|
||||
// navigate("/login/manual");
|
||||
};
|
||||
const users = Route.useLoaderData();
|
||||
|
||||
const handleQuickConnect = async () => {
|
||||
setQuickConnectLoading(0);
|
||||
|
||||
const quickApi = getQuickConnectApi(api);
|
||||
|
||||
const headers = {
|
||||
"X-Emby-Authorization": `MediaBrowser Client="${api.clientInfo.name}", Device="${api.deviceInfo.name}", DeviceId="${api.deviceInfo.id}", Version="${api.clientInfo.version}"`,
|
||||
};
|
||||
|
||||
const quickConnectInitiation = await quickApi
|
||||
.initiate({
|
||||
headers,
|
||||
})
|
||||
.catch(() => ({ status: 401 }));
|
||||
|
||||
if (quickConnectInitiation.status !== 200) {
|
||||
setQuickConnectLoading(-1);
|
||||
enqueueSnackbar("Unable to use Quick Connect", {
|
||||
variant: "error",
|
||||
});
|
||||
return;
|
||||
}
|
||||
|
||||
setQuickConnectLoading(1);
|
||||
|
||||
const { Secret, Code } = quickConnectInitiation.data;
|
||||
|
||||
setQuickConnectCode(Code);
|
||||
|
||||
const interval = setInterval(async () => {
|
||||
const quickConnectCheck = await quickApi
|
||||
.connect({
|
||||
secret: Secret,
|
||||
})
|
||||
.catch(() => ({ status: 401, data: { Authenticated: false } }));
|
||||
|
||||
if (quickConnectCheck.status !== 200) {
|
||||
setQuickConnectCode("");
|
||||
enqueueSnackbar("Unable to use Quick Connect", {
|
||||
variant: "error",
|
||||
});
|
||||
|
||||
setQuickConnectLoading(-1);
|
||||
clearInterval(interval);
|
||||
return;
|
||||
}
|
||||
|
||||
if (!quickConnectCheck.data.Authenticated) {
|
||||
return;
|
||||
}
|
||||
|
||||
const auth = await getUserApi(api)
|
||||
.authenticateWithQuickConnect({
|
||||
quickConnectDto: {
|
||||
Secret: Secret,
|
||||
},
|
||||
})
|
||||
.catch(() => ({ status: 401 }));
|
||||
|
||||
api.accessToken = auth.data.AccessToken;
|
||||
|
||||
clearInterval(interval);
|
||||
|
||||
if (auth.status !== 200) {
|
||||
enqueueSnackbar("Unable to use Quick Connect", {
|
||||
variant: "error",
|
||||
});
|
||||
setQuickConnectLoading(-1);
|
||||
return;
|
||||
}
|
||||
|
||||
sessionStorage.setItem("accessToken", auth.data.AccessToken);
|
||||
createApi(api.basePath, auth.data.AccessToken);
|
||||
|
||||
if (rememberMe === true) {
|
||||
await saveUser(auth.data.User.Name, auth.data.AccessToken);
|
||||
}
|
||||
|
||||
setQuickConnectLoading(-1);
|
||||
enqueueSnackbar(`Logged in as ${auth.data.User.Name}!`, {
|
||||
variant: "success",
|
||||
});
|
||||
navigate("/home");
|
||||
}, 1000);
|
||||
|
||||
setLoading(false);
|
||||
};
|
||||
|
||||
useLayoutEffect(() => {
|
||||
setBackdrop("", "");
|
||||
}, []);
|
||||
|
||||
if (users.isPending) {
|
||||
return <LinearProgress />;
|
||||
}
|
||||
|
||||
if (users.isSuccess) {
|
||||
return (
|
||||
<>
|
||||
<AppBarBackOnly />
|
||||
<Container
|
||||
maxWidth="md"
|
||||
sx={{
|
||||
height: "100vh",
|
||||
display: "flex",
|
||||
flexDirection: "column",
|
||||
justifyContent: "center",
|
||||
alignItems: "center",
|
||||
}}
|
||||
>
|
||||
<Typography variant="h3" mb={2}>
|
||||
Users
|
||||
</Typography>
|
||||
|
||||
<Grid
|
||||
container
|
||||
columns={{
|
||||
xs: 2,
|
||||
sm: 3,
|
||||
md: 4,
|
||||
}}
|
||||
wrap="nowrap"
|
||||
alignItems="center"
|
||||
overflow="auto"
|
||||
width="100%"
|
||||
mb={3}
|
||||
paddingBottom={2}
|
||||
className="roundedScrollbar"
|
||||
>
|
||||
{users.data.map((item, index) => {
|
||||
return (
|
||||
<Grid
|
||||
key={item.Id}
|
||||
flexShrink={0}
|
||||
flexGrow={1}
|
||||
xs={1}
|
||||
sm={1}
|
||||
md={1}
|
||||
>
|
||||
<Card
|
||||
cardTitle={item.Name}
|
||||
item={item}
|
||||
disableOverlay
|
||||
itemType="User"
|
||||
cardType="square"
|
||||
onClick={() =>
|
||||
navigate(`/login/withImg/${item.Name}/${item.Id}/`)
|
||||
}
|
||||
overrideIcon="User"
|
||||
imageType="Primary"
|
||||
/>
|
||||
</Grid>
|
||||
);
|
||||
})}
|
||||
</Grid>
|
||||
|
||||
<div className="buttons">
|
||||
<Button
|
||||
color="secondary"
|
||||
variant="contained"
|
||||
className="userEventButton"
|
||||
onClick={handleChangeServer}
|
||||
>
|
||||
Change Server
|
||||
</Button>
|
||||
<LoadingButton
|
||||
onClick={handleQuickConnect}
|
||||
variant="contained"
|
||||
className="userEventButton"
|
||||
sx={{ width: "100%" }}
|
||||
loading={quickConnectLoading === 1}
|
||||
size="large"
|
||||
>
|
||||
Quick Connect
|
||||
</LoadingButton>
|
||||
<Button
|
||||
variant="contained"
|
||||
className="userEventButton"
|
||||
onClick={handleManualLogin}
|
||||
size="small"
|
||||
>
|
||||
Manual Login
|
||||
</Button>
|
||||
</div>
|
||||
|
||||
<Dialog open={Boolean(quickConnectCode)} fullWidth maxWidth="xs">
|
||||
<DialogContent
|
||||
style={{
|
||||
display: "flex",
|
||||
flexDirection: "column",
|
||||
alignItems: "center",
|
||||
}}
|
||||
>
|
||||
<Typography
|
||||
variant="h5"
|
||||
mb={2}
|
||||
style={{
|
||||
width: "100%",
|
||||
}}
|
||||
>
|
||||
Quick Connect Code:
|
||||
</Typography>
|
||||
<DialogContentText>
|
||||
Use this code in the Quick Connect tab in your server to login.
|
||||
</DialogContentText>
|
||||
<div
|
||||
className="flex flex-row"
|
||||
style={{ gap: "1em", alignItems: "center", marginTop: "1em" }}
|
||||
>
|
||||
<Tooltip title="Click to copy" arrow placement="top">
|
||||
<Typography
|
||||
variant="h3"
|
||||
color="textPrimary"
|
||||
textAlign="center"
|
||||
sx={{
|
||||
background: "rgb(255 255 255 / 0.1)",
|
||||
width: "fit-content",
|
||||
padding: "0.4em",
|
||||
borderRadius: "10px",
|
||||
cursor: "pointer",
|
||||
}}
|
||||
onClick={(e) => {
|
||||
navigator.clipboard.writeText(quickConnectCode);
|
||||
enqueueSnackbar("Quick Connect Code copied!", {
|
||||
variant: "info",
|
||||
key: "copiedText",
|
||||
});
|
||||
}}
|
||||
>
|
||||
{quickConnectCode}
|
||||
</Typography>
|
||||
</Tooltip>
|
||||
</div>
|
||||
</DialogContent>
|
||||
<DialogActions
|
||||
className="flex flex-row"
|
||||
sx={{
|
||||
padding: "0em 1em 1em 1em",
|
||||
justifyContent: "space-between",
|
||||
}}
|
||||
>
|
||||
<FormControlLabel
|
||||
control={
|
||||
<Checkbox
|
||||
checked={rememberMe}
|
||||
onChange={handleCheckRememberMe}
|
||||
/>
|
||||
}
|
||||
label="Remember device"
|
||||
/>
|
||||
<Button
|
||||
variant="contained"
|
||||
onClick={() => {
|
||||
setQuickConnectCode("");
|
||||
setQuickConnectLoading(-1);
|
||||
}}
|
||||
>
|
||||
Close
|
||||
</Button>
|
||||
</DialogActions>
|
||||
</Dialog>
|
||||
</Container>
|
||||
</>
|
||||
);
|
||||
}
|
||||
if (users.isError) {
|
||||
return <ErrorNotice />;
|
||||
}
|
||||
}
|
||||
File renamed without changes.
@@ -0,0 +1,448 @@
|
||||
import { queryOptions, useQuery } from "@tanstack/react-query";
|
||||
import React, { useLayoutEffect, useState } from "react";
|
||||
|
||||
import { saveUser } from "@/utils/storage/user.js";
|
||||
|
||||
import LoadingButton from "@mui/lab/LoadingButton";
|
||||
import {
|
||||
Dialog,
|
||||
DialogActions,
|
||||
DialogContent,
|
||||
DialogContentText,
|
||||
Grid,
|
||||
OutlinedInput,
|
||||
Paper,
|
||||
Tooltip,
|
||||
Typography,
|
||||
} from "@mui/material";
|
||||
import Button from "@mui/material/Button";
|
||||
import Checkbox from "@mui/material/Checkbox";
|
||||
import Container from "@mui/material/Container";
|
||||
import FormControl from "@mui/material/FormControl";
|
||||
import FormControlLabel from "@mui/material/FormControlLabel";
|
||||
import FormGroup from "@mui/material/FormGroup";
|
||||
import IconButton from "@mui/material/IconButton";
|
||||
import InputAdornment from "@mui/material/InputAdornment";
|
||||
import InputLabel from "@mui/material/InputLabel";
|
||||
|
||||
import { useSnackbar } from "notistack";
|
||||
|
||||
import { AppBarBackOnly } from "@/components/appBar/backOnly.jsx";
|
||||
import { createApi, useApiInContext } from "@/utils/store/api.js";
|
||||
import { getBrandingApi } from "@jellyfin/sdk/lib/utils/api/branding-api";
|
||||
import { getQuickConnectApi } from "@jellyfin/sdk/lib/utils/api/quick-connect-api";
|
||||
import { getUserApi } from "@jellyfin/sdk/lib/utils/api/user-api";
|
||||
import "./login.scss";
|
||||
|
||||
import { queryClient } from "@/main.js";
|
||||
import { setBackdrop } from "@/utils/store/backdrop.js";
|
||||
import { blue } from "@mui/material/colors";
|
||||
import { createFileRoute, useNavigate } from "@tanstack/react-router";
|
||||
import { redirect } from "@tanstack/react-router";
|
||||
|
||||
export const Route = createFileRoute("/_api/login/manual")({
|
||||
component: UserLoginManual,
|
||||
});
|
||||
|
||||
function UserLoginManual() {
|
||||
const [loading, setLoading] = useState(false);
|
||||
const [quickConnectLoading, setQuickConnectLoading] = useState(-1);
|
||||
const [quickConnectCode, setQuickConnectCode] = useState("");
|
||||
const [rememberMe, setRememberMe] = useState(true);
|
||||
const api = Route.useRouteContext().api;
|
||||
|
||||
const server = useQuery({
|
||||
queryKey: ["login", "manual", "serverInfo"],
|
||||
queryFn: async () => {
|
||||
return (await getBrandingApi(api).getBrandingOptions()).data;
|
||||
},
|
||||
});
|
||||
|
||||
const navigate = useNavigate();
|
||||
const { enqueueSnackbar } = useSnackbar();
|
||||
|
||||
const [password, setPassword] = useState({
|
||||
showpass: false,
|
||||
});
|
||||
const [userName, setUserName] = useState("");
|
||||
|
||||
const handleUsername = (event) => {
|
||||
setUserName(event.target.value);
|
||||
};
|
||||
|
||||
const handlePassword = (prop) => (event) => {
|
||||
setPassword({
|
||||
...password,
|
||||
[prop]: event.target.value,
|
||||
});
|
||||
};
|
||||
|
||||
const handleShowPassword = () => {
|
||||
setPassword({
|
||||
...password,
|
||||
showpass: !password.showpass,
|
||||
});
|
||||
};
|
||||
|
||||
const authUser = async () => {
|
||||
try {
|
||||
const auth = await api.authenticateUserByName(
|
||||
userName,
|
||||
password.password,
|
||||
);
|
||||
return auth;
|
||||
} catch (error) {
|
||||
enqueueSnackbar("Incorrect Username or Password!", {
|
||||
variant: "error",
|
||||
});
|
||||
setLoading(false);
|
||||
console.error(error);
|
||||
}
|
||||
};
|
||||
|
||||
const handleLogin = async () => {
|
||||
setLoading(true);
|
||||
const user = await authUser();
|
||||
sessionStorage.setItem("accessToken", user.data.AccessToken);
|
||||
createApi(api.basePath, user.data.AccessToken);
|
||||
if (rememberMe === true) {
|
||||
await saveUser(userName, user.data.AccessToken);
|
||||
}
|
||||
setLoading(false);
|
||||
navigate("/home");
|
||||
};
|
||||
|
||||
const handleCheckRememberMe = (event) => {
|
||||
setRememberMe(event.target.checked);
|
||||
};
|
||||
|
||||
const handleQuickConnect = async () => {
|
||||
setQuickConnectLoading(0);
|
||||
|
||||
const quickApi = getQuickConnectApi(api);
|
||||
|
||||
const headers = {
|
||||
"X-Emby-Authorization": `MediaBrowser Client="${api.clientInfo.name}", Device="${api.deviceInfo.name}", DeviceId="${api.deviceInfo.id}", Version="${api.clientInfo.version}"`,
|
||||
};
|
||||
|
||||
const quickConnectInitiation = await quickApi
|
||||
.initiate({
|
||||
headers,
|
||||
})
|
||||
.catch(() => ({ status: 401 }));
|
||||
|
||||
if (quickConnectInitiation.status !== 200) {
|
||||
setQuickConnectCode("");
|
||||
setQuickConnectLoading(-1);
|
||||
enqueueSnackbar("Unable to use Quick Connect", {
|
||||
variant: "error",
|
||||
});
|
||||
return;
|
||||
}
|
||||
|
||||
setQuickConnectLoading(1);
|
||||
|
||||
const { Secret, Code } = quickConnectInitiation.data;
|
||||
|
||||
setQuickConnectCode(Code);
|
||||
|
||||
const interval = setInterval(async () => {
|
||||
const quickConnectCheck = await quickApi
|
||||
.connect({
|
||||
secret: Secret,
|
||||
})
|
||||
.catch(() => ({ status: 401, data: { Authenticated: false } }));
|
||||
|
||||
if (quickConnectCheck.status !== 200) {
|
||||
enqueueSnackbar("Unable to use Quick Connect", {
|
||||
variant: "error",
|
||||
});
|
||||
|
||||
setQuickConnectLoading(-1);
|
||||
clearInterval(interval);
|
||||
return;
|
||||
}
|
||||
|
||||
if (!quickConnectCheck.data.Authenticated) {
|
||||
return;
|
||||
}
|
||||
|
||||
const auth = await getUserApi(api)
|
||||
.authenticateWithQuickConnect({
|
||||
quickConnectDto: {
|
||||
Secret: Secret,
|
||||
},
|
||||
})
|
||||
.catch(() => ({ status: 401 }));
|
||||
|
||||
api.accessToken = auth.data.AccessToken;
|
||||
|
||||
clearInterval(interval);
|
||||
|
||||
if (auth.status !== 200) {
|
||||
enqueueSnackbar("Unable to use Quick Connect", {
|
||||
variant: "error",
|
||||
});
|
||||
setQuickConnectLoading(-1);
|
||||
return;
|
||||
}
|
||||
|
||||
sessionStorage.setItem("accessToken", auth.data.AccessToken);
|
||||
createApi(api.basePath, auth.data.AccessToken);
|
||||
|
||||
if (rememberMe === true) {
|
||||
await saveUser(userName, auth.data.AccessToken);
|
||||
}
|
||||
|
||||
setQuickConnectLoading(-1);
|
||||
enqueueSnackbar(`Logged in as ${auth.data.User.Name}!`, {
|
||||
variant: "success",
|
||||
});
|
||||
navigate("/home");
|
||||
}, 1000);
|
||||
|
||||
setLoading(false);
|
||||
};
|
||||
|
||||
useLayoutEffect(() => {
|
||||
setBackdrop("", "");
|
||||
}, []);
|
||||
|
||||
return (
|
||||
<>
|
||||
<AppBarBackOnly />
|
||||
<Container
|
||||
maxWidth="xs"
|
||||
sx={{
|
||||
height: "100vh",
|
||||
display: "flex",
|
||||
justifyContent: "center",
|
||||
alignItems: "center",
|
||||
}}
|
||||
>
|
||||
<Grid
|
||||
container
|
||||
spacing={2}
|
||||
direction="column"
|
||||
justifyContent="center"
|
||||
alignItems="center"
|
||||
sx={{
|
||||
transition: "opacity 200ms",
|
||||
width: "100%",
|
||||
}}
|
||||
>
|
||||
<Grid sx={{ marginBottom: "1em" }}>
|
||||
<Typography variant="h3" color="textPrimary">
|
||||
Login
|
||||
</Typography>
|
||||
</Grid>
|
||||
<Grid sx={{ width: "100%", mb: 1 }}>
|
||||
<FormControl sx={{ width: "100%" }} variant="outlined">
|
||||
<InputLabel htmlFor="user-name">Username:</InputLabel>
|
||||
<OutlinedInput
|
||||
fullWidth
|
||||
id="user-name"
|
||||
type="text"
|
||||
variant="outlined"
|
||||
label="Username:"
|
||||
onChange={handleUsername}
|
||||
/>
|
||||
</FormControl>
|
||||
</Grid>
|
||||
<Grid sx={{ width: "100%" }}>
|
||||
<FormGroup>
|
||||
<FormControl sx={{ width: "100%" }} variant="outlined">
|
||||
<InputLabel htmlFor="user-password">Password:</InputLabel>
|
||||
<OutlinedInput
|
||||
fullWidth
|
||||
id="user-password"
|
||||
type={password.showpass ? "text" : "password"}
|
||||
variant="outlined"
|
||||
onChange={handlePassword("password")}
|
||||
onKeyUp={(event) => {
|
||||
if (event.key === "Enter") {
|
||||
handleLogin();
|
||||
}
|
||||
}}
|
||||
label="Password:"
|
||||
endAdornment={
|
||||
<InputAdornment position="end">
|
||||
<IconButton
|
||||
onClick={handleShowPassword}
|
||||
aria-label="toggle password visibility"
|
||||
>
|
||||
{password.showpass ? (
|
||||
<span className="material-symbols-rounded">
|
||||
visibility
|
||||
</span>
|
||||
) : (
|
||||
<span className="material-symbols-rounded">
|
||||
visibility_off
|
||||
</span>
|
||||
)}
|
||||
</IconButton>
|
||||
</InputAdornment>
|
||||
}
|
||||
/>
|
||||
</FormControl>
|
||||
<FormControlLabel
|
||||
control={
|
||||
<Checkbox
|
||||
checked={rememberMe}
|
||||
onChange={handleCheckRememberMe}
|
||||
/>
|
||||
}
|
||||
label="Remember me"
|
||||
/>
|
||||
</FormGroup>
|
||||
</Grid>
|
||||
<div
|
||||
className="flex flex-column"
|
||||
style={{ width: "100%", gap: "0.4em" }}
|
||||
>
|
||||
<LoadingButton
|
||||
variant="contained"
|
||||
endIcon={
|
||||
<span className="material-symbols-rounded">chevron_right</span>
|
||||
}
|
||||
onClick={handleLogin}
|
||||
loading={loading}
|
||||
loadingPosition="end"
|
||||
size="large"
|
||||
sx={{ width: "100%" }}
|
||||
>
|
||||
Login
|
||||
</LoadingButton>
|
||||
<LoadingButton
|
||||
onClick={handleQuickConnect}
|
||||
variant="contained"
|
||||
className="userEventButton"
|
||||
sx={{ width: "100%" }}
|
||||
loading={quickConnectLoading === 1}
|
||||
// size="large"
|
||||
>
|
||||
Quick Connect
|
||||
</LoadingButton>
|
||||
<Button
|
||||
color="secondary"
|
||||
variant="contained"
|
||||
className="userEventButton"
|
||||
// size="large"
|
||||
sx={{ width: "100%" }}
|
||||
onClick={() => navigate("/servers/list")}
|
||||
>
|
||||
Change Server
|
||||
</Button>
|
||||
</div>
|
||||
<Dialog open={Boolean(quickConnectCode)} fullWidth maxWidth="xs">
|
||||
<DialogContent
|
||||
style={{
|
||||
display: "flex",
|
||||
flexDirection: "column",
|
||||
alignItems: "center",
|
||||
}}
|
||||
>
|
||||
<Typography
|
||||
variant="h5"
|
||||
mb={2}
|
||||
style={{
|
||||
width: "100%",
|
||||
}}
|
||||
>
|
||||
Quick Connect Code:
|
||||
</Typography>
|
||||
<DialogContentText>
|
||||
Use this code in the Quick Connect tab in your server to login.
|
||||
</DialogContentText>
|
||||
<div
|
||||
className="flex flex-row"
|
||||
style={{ gap: "1em", alignItems: "center", marginTop: "1em" }}
|
||||
>
|
||||
<Tooltip title="Click to copy" arrow placement="top">
|
||||
<Typography
|
||||
variant="h3"
|
||||
color="textPrimary"
|
||||
textAlign="center"
|
||||
sx={{
|
||||
background: "rgb(255 255 255 / 0.1)",
|
||||
width: "fit-content",
|
||||
padding: "0.4em",
|
||||
borderRadius: "10px",
|
||||
cursor: "pointer",
|
||||
}}
|
||||
onClick={(e) => {
|
||||
navigator.clipboard.writeText(quickConnectCode);
|
||||
enqueueSnackbar("Quick Connect Code copied!", {
|
||||
variant: "info",
|
||||
key: "copiedText",
|
||||
});
|
||||
}}
|
||||
>
|
||||
{quickConnectCode}
|
||||
</Typography>
|
||||
</Tooltip>
|
||||
</div>
|
||||
</DialogContent>
|
||||
<DialogActions
|
||||
className="flex flex-row"
|
||||
sx={{
|
||||
padding: "0em 1em 1em 1em",
|
||||
justifyContent: "space-between",
|
||||
}}
|
||||
>
|
||||
<FormControlLabel
|
||||
control={
|
||||
<Checkbox
|
||||
checked={rememberMe}
|
||||
onChange={handleCheckRememberMe}
|
||||
/>
|
||||
}
|
||||
label="Remember device"
|
||||
/>
|
||||
<Button
|
||||
variant="contained"
|
||||
onClick={() => {
|
||||
setQuickConnectCode("");
|
||||
setQuickConnectLoading(-1);
|
||||
}}
|
||||
>
|
||||
Close
|
||||
</Button>
|
||||
</DialogActions>
|
||||
</Dialog>
|
||||
<Grid sx={{ width: "100%" }}>
|
||||
{server.isSuccess && server.data.LoginDisclaimer && (
|
||||
<Paper
|
||||
elevation={5}
|
||||
style={{
|
||||
marginTop: "1em",
|
||||
padding: "1em",
|
||||
borderRadius: "15px",
|
||||
}}
|
||||
>
|
||||
<div
|
||||
className="flex flex-row flex-align-center"
|
||||
style={{ gap: "0.5em", marginBottom: "0.5em" }}
|
||||
>
|
||||
<span
|
||||
className="material-symbols-rounded"
|
||||
style={{
|
||||
color: blue[700],
|
||||
"--fill": 1,
|
||||
}}
|
||||
>
|
||||
info
|
||||
</span>
|
||||
Notice
|
||||
</div>
|
||||
<Typography variant="subtitle2" style={{ opacity: 0.8 }}>
|
||||
{server.data.LoginDisclaimer}
|
||||
</Typography>
|
||||
</Paper>
|
||||
)}
|
||||
</Grid>
|
||||
</Grid>
|
||||
</Container>
|
||||
</>
|
||||
);
|
||||
}
|
||||
@@ -1,5 +1,5 @@
|
||||
import PropTypes from "prop-types";
|
||||
import React, { useState, useEffect, useLayoutEffect, useRef } from "react";
|
||||
import React, { useState, useLayoutEffect, useRef } from "react";
|
||||
|
||||
import Box from "@mui/material/Box";
|
||||
import CircularProgress from "@mui/material/CircularProgress";
|
||||
@@ -8,10 +8,8 @@ import Tab from "@mui/material/Tab";
|
||||
import Tabs from "@mui/material/Tabs";
|
||||
import Typography from "@mui/material/Typography";
|
||||
|
||||
import useParallax from "@/utils/hooks/useParallax";
|
||||
import { AnimatePresence, motion, useScroll } from "framer-motion";
|
||||
import useParallax from "../../utils/hooks/useParallax";
|
||||
|
||||
import { Link, useParams } from "react-router-dom";
|
||||
|
||||
import {
|
||||
BaseItemKind,
|
||||
@@ -22,21 +20,21 @@ import { getItemsApi } from "@jellyfin/sdk/lib/utils/api/items-api";
|
||||
import { getUserApi } from "@jellyfin/sdk/lib/utils/api/user-api";
|
||||
import { getUserLibraryApi } from "@jellyfin/sdk/lib/utils/api/user-library-api";
|
||||
|
||||
import { Card } from "@/components/card/card";
|
||||
import { useQuery } from "@tanstack/react-query";
|
||||
import { Card } from "../../components/card/card";
|
||||
|
||||
import { Blurhash } from "react-blurhash";
|
||||
|
||||
import LikeButton from "../../components/buttons/likeButton";
|
||||
import { ErrorNotice } from "../../components/notices/errorNotice/errorNotice";
|
||||
import { useApi } from "../../utils/store/api";
|
||||
import { setBackdrop } from "../../utils/store/backdrop";
|
||||
import LikeButton from "@/components/buttons/likeButton";
|
||||
import { ErrorNotice } from "@/components/notices/errorNotice/errorNotice";
|
||||
import { setBackdrop } from "@/utils/store/backdrop";
|
||||
|
||||
import meshBg from "../../assets/herobg.png";
|
||||
import ShowMoreText from "../../components/showMoreText";
|
||||
import meshBg from "@/assets/herobg.png";
|
||||
import ShowMoreText from "@/components/showMoreText";
|
||||
import "./person.scss";
|
||||
|
||||
import IconLink from "../../components/iconLink";
|
||||
import IconLink from "@/components/iconLink";
|
||||
import { createFileRoute } from "@tanstack/react-router";
|
||||
|
||||
function TabPanel(props) {
|
||||
const { children, value, index, ...other } = props;
|
||||
@@ -68,9 +66,13 @@ function a11yProps(index) {
|
||||
};
|
||||
}
|
||||
|
||||
const PersonTitlePage = () => {
|
||||
const { id } = useParams();
|
||||
const [api] = useApi((state) => [state.api]);
|
||||
export const Route = createFileRoute("/_api/person/$id")({
|
||||
component: PersonTitlePage,
|
||||
});
|
||||
|
||||
function PersonTitlePage() {
|
||||
const { id } = Route.useParams();
|
||||
const api = Route.useRouteContext().api;
|
||||
|
||||
const user = useQuery({
|
||||
queryKey: ["user"],
|
||||
@@ -511,6 +513,6 @@ const PersonTitlePage = () => {
|
||||
if (item.isError) {
|
||||
return <ErrorNotice />;
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
export default PersonTitlePage;
|
||||
File renamed without changes.
File renamed without changes.
@@ -14,11 +14,11 @@ import Typography from "@mui/material/Typography";
|
||||
|
||||
import ReactPlayer from "react-player";
|
||||
|
||||
import { usePlaybackStore } from "../../utils/store/playback";
|
||||
import { usePlaybackStore } from "@/utils/store/playback";
|
||||
|
||||
import { getRuntimeMusic, secToTicks, ticksToSec } from "@/utils/date/time";
|
||||
import { useCallback, useEffect, useRef, useState } from "react";
|
||||
import { Navigate, useNavigate } from "react-router-dom";
|
||||
import { getRuntimeMusic, secToTicks, ticksToSec } from "../../utils/date/time";
|
||||
|
||||
import { getMediaInfoApi } from "@jellyfin/sdk/lib/utils/api/media-info-api";
|
||||
import { getPlaystateApi } from "@jellyfin/sdk/lib/utils/api/playstate-api";
|
||||
@@ -26,26 +26,30 @@ import { getTvShowsApi } from "@jellyfin/sdk/lib/utils/api/tv-shows-api";
|
||||
|
||||
import "./videoPlayer.scss";
|
||||
|
||||
import { endsAt } from "../../utils/date/time";
|
||||
import { endsAt } from "@/utils/date/time";
|
||||
|
||||
import { useQuery } from "@tanstack/react-query";
|
||||
|
||||
import { ItemFields, LocationType, PlayMethod, RepeatMode } from "@jellyfin/sdk/lib/generated-client";
|
||||
import {
|
||||
ItemFields,
|
||||
LocationType,
|
||||
PlayMethod,
|
||||
RepeatMode,
|
||||
} from "@jellyfin/sdk/lib/generated-client";
|
||||
import { AnimatePresence, motion } from "framer-motion";
|
||||
|
||||
import useDebounce from "../../utils/hooks/useDebounce";
|
||||
import { useApi } from "../../utils/store/api";
|
||||
import { setBackdrop } from "../../utils/store/backdrop";
|
||||
import { setBackdrop } from "@/utils/store/backdrop";
|
||||
|
||||
import { FormControl, TextField } from "@mui/material";
|
||||
import type JASSUB from "jassub";
|
||||
import workerUrl from "jassub/dist/jassub-worker.js?url";
|
||||
import wasmUrl from "jassub/dist/jassub-worker.wasm?url";
|
||||
|
||||
import PlayNextButton from "@/components/buttons/playNextButton";
|
||||
import PlayPreviousButton from "@/components/buttons/playPreviousButtom";
|
||||
import QueueButton from "@/components/buttons/queueButton";
|
||||
import { getUserApi } from "@jellyfin/sdk/lib/utils/api/user-api";
|
||||
import PlayNextButton from "src/components/buttons/playNextButton";
|
||||
import PlayPreviousButton from "src/components/buttons/playPreviousButtom";
|
||||
import QueueButton from "src/components/buttons/queueButton";
|
||||
import { createFileRoute, useRouter } from "@tanstack/react-router";
|
||||
import subtitleFont from "./Noto-Sans-Indosphere.ttf";
|
||||
|
||||
const ticksDisplay = (ticks: number) => {
|
||||
@@ -70,10 +74,13 @@ const ticksDisplay = (ticks: number) => {
|
||||
return formatedTime;
|
||||
};
|
||||
|
||||
const VideoPlayer = () => {
|
||||
const navigate = useNavigate();
|
||||
const [api] = useApi((state) => [state.api]);
|
||||
export const Route = createFileRoute("/_api/player/")({
|
||||
component: VideoPlayer,
|
||||
});
|
||||
|
||||
function VideoPlayer() {
|
||||
const api = Route.useRouteContext().api;
|
||||
const { history } = useRouter();
|
||||
const [hoveringOsd, setHoveringOsd] = useState(false);
|
||||
|
||||
const [
|
||||
@@ -115,12 +122,12 @@ const VideoPlayer = () => {
|
||||
mediaSource.subtitleTrack,
|
||||
);
|
||||
const [volume, setVolume] = useState(1);
|
||||
const [muted, setMuted]= useState(false)
|
||||
const [muted, setMuted] = useState(false);
|
||||
|
||||
useEffect(() => setBackdrop("", ""), []);
|
||||
|
||||
const [subtitleRenderer, setSubtitleRenderer] = useState<JASSUB>(null);
|
||||
|
||||
|
||||
const handleReady = async () => {
|
||||
if (!isReady) {
|
||||
if (selectedSubtitle !== "nosub") {
|
||||
@@ -185,17 +192,14 @@ const VideoPlayer = () => {
|
||||
if (subtitleRenderer) {
|
||||
subtitleRenderer.destroy();
|
||||
}
|
||||
navigate(-1);
|
||||
history.back();
|
||||
// Report Jellyfin server: Playback has ended/stopped
|
||||
getPlaystateApi(api).reportPlaybackStopped({
|
||||
playbackStopInfo: {
|
||||
Failed: false,
|
||||
Item: item,
|
||||
ItemId: item?.Id,
|
||||
MediaSourceId: mediaSource.id,
|
||||
PlayMethod: PlayMethod.DirectPlay,
|
||||
PlaySessionId: playsessionId,
|
||||
PlaybackStartTimeTicks: startPosition,
|
||||
PositionTicks: progress,
|
||||
},
|
||||
});
|
||||
@@ -236,8 +240,8 @@ const VideoPlayer = () => {
|
||||
case "F":
|
||||
case "f":
|
||||
setAppFullscreen((state) => {
|
||||
appWindow.setFullscreen(!state)
|
||||
return !state
|
||||
appWindow.setFullscreen(!state);
|
||||
return !state;
|
||||
});
|
||||
break;
|
||||
case "P":
|
||||
@@ -585,6 +589,6 @@ const VideoPlayer = () => {
|
||||
/>
|
||||
</div>
|
||||
);
|
||||
};
|
||||
}
|
||||
|
||||
export default VideoPlayer;
|
||||
File renamed without changes.
@@ -4,8 +4,6 @@ import React, { useEffect } from "react";
|
||||
import Box from "@mui/material/Box";
|
||||
import CircularProgress from "@mui/material/CircularProgress";
|
||||
|
||||
import { useParams } from "react-router-dom";
|
||||
|
||||
import { BaseItemKind, ItemFields } from "@jellyfin/sdk/lib/generated-client";
|
||||
import { getLibraryApi } from "@jellyfin/sdk/lib/utils/api/library-api";
|
||||
import { getPlaylistsApi } from "@jellyfin/sdk/lib/utils/api/playlists-api";
|
||||
@@ -14,15 +12,14 @@ import { getUserLibraryApi } from "@jellyfin/sdk/lib/utils/api/user-library-api"
|
||||
|
||||
import { useQuery } from "@tanstack/react-query";
|
||||
|
||||
import { Card } from "../../components/card/card";
|
||||
import { CardScroller } from "../../components/cardScroller/cardScroller";
|
||||
import Hero from "../../components/layouts/item/hero";
|
||||
import { Card } from "@/components/card/card";
|
||||
import { CardScroller } from "@/components/cardScroller/cardScroller";
|
||||
|
||||
import MusicTrack from "../../components/musicTrack";
|
||||
import { ErrorNotice } from "../../components/notices/errorNotice/errorNotice";
|
||||
import { useApi } from "../../utils/store/api";
|
||||
import { useBackdropStore } from "../../utils/store/backdrop";
|
||||
import MusicTrack from "@/components/musicTrack";
|
||||
import { ErrorNotice } from "@/components/notices/errorNotice/errorNotice";
|
||||
import { useBackdropStore } from "@/utils/store/backdrop";
|
||||
import "./playlist.scss";
|
||||
import { createFileRoute } from "@tanstack/react-router";
|
||||
function TabPanel(props) {
|
||||
const { children, value, index, ...other } = props;
|
||||
|
||||
@@ -53,9 +50,13 @@ function a11yProps(index) {
|
||||
};
|
||||
}
|
||||
|
||||
const PlaylistTitlePage = () => {
|
||||
const { id } = useParams();
|
||||
const [api] = useApi((state) => [state.api]);
|
||||
export const Route = createFileRoute("/_api/playlist/$id")({
|
||||
component: PlaylistTitlePage,
|
||||
});
|
||||
|
||||
function PlaylistTitlePage() {
|
||||
const { id } = Route.useParams();
|
||||
const api = Route.useRouteContext().api;
|
||||
|
||||
const user = useQuery({
|
||||
queryKey: ["user"],
|
||||
@@ -122,7 +123,7 @@ const PlaylistTitlePage = () => {
|
||||
item.data.Id,
|
||||
);
|
||||
}
|
||||
});
|
||||
}, []);
|
||||
|
||||
if (item.isPending || similarItems.isPending) {
|
||||
return (
|
||||
@@ -142,7 +143,7 @@ const PlaylistTitlePage = () => {
|
||||
if (item.isSuccess && similarItems.isSuccess) {
|
||||
return (
|
||||
<div
|
||||
className="scrollY"
|
||||
className="scrollY padded-top item"
|
||||
style={{
|
||||
padding: "5em 2em 2em 1em",
|
||||
display: "flex",
|
||||
@@ -150,15 +151,6 @@ const PlaylistTitlePage = () => {
|
||||
gap: "0.5em",
|
||||
}}
|
||||
>
|
||||
<Hero
|
||||
item={item.data}
|
||||
userId={user.data.Id}
|
||||
queryKey={["item", id]}
|
||||
artists={item.data.ArtistItems}
|
||||
disableMarkAsPlayedButton
|
||||
audioPlayButton
|
||||
cardType="square"
|
||||
/>
|
||||
{musicTracks.isPending ? (
|
||||
<></>
|
||||
) : (
|
||||
@@ -200,14 +192,14 @@ const PlaylistTitlePage = () => {
|
||||
similar.Type === BaseItemKind.Episode
|
||||
? `S${similar.ParentIndexNumber}:E${similar.IndexNumber} - ${similar.Name}`
|
||||
: similar.Type === BaseItemKind.Series
|
||||
? `${similar.ProductionYear} - ${
|
||||
? `${similar.ProductionYear} - ${
|
||||
similar.EndDate
|
||||
? new Date(similar.EndDate).toLocaleString([], {
|
||||
year: "numeric",
|
||||
})
|
||||
})
|
||||
: "Present"
|
||||
}`
|
||||
: similar.ProductionYear
|
||||
}`
|
||||
: similar.ProductionYear
|
||||
}
|
||||
cardType={
|
||||
similar.Type === BaseItemKind.MusicAlbum ||
|
||||
@@ -234,6 +226,6 @@ const PlaylistTitlePage = () => {
|
||||
if (item.isError || similarItems.isError) {
|
||||
return <ErrorNotice />;
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
export default PlaylistTitlePage;
|
||||
File renamed without changes.
@@ -4,27 +4,31 @@ import CircularProgress from "@mui/material/CircularProgress";
|
||||
import InputAdornment from "@mui/material/InputAdornment";
|
||||
import TextField from "@mui/material/TextField";
|
||||
|
||||
import { useBackdropStore } from "../../utils/store/backdrop";
|
||||
import { useBackdropStore } from "@/utils/store/backdrop";
|
||||
|
||||
import { useQuery } from "@tanstack/react-query";
|
||||
|
||||
import { EmptyNotice } from "@/components/notices/emptyNotice/emptyNotice";
|
||||
import { getUserApi } from "@jellyfin/sdk/lib/utils/api/user-api";
|
||||
import { EmptyNotice } from "../../components/notices/emptyNotice/emptyNotice";
|
||||
|
||||
import useDebounce from "../../utils/hooks/useDebounce";
|
||||
import useDebounce from "@/utils/hooks/useDebounce";
|
||||
|
||||
import { Card } from "@/components/card/card";
|
||||
import { EpisodeCard } from "@/components/card/episodeCard";
|
||||
import { CardScroller } from "@/components/cardScroller/cardScroller";
|
||||
import { BaseItemKind } from "@jellyfin/sdk/lib/generated-client";
|
||||
import { getItemsApi } from "@jellyfin/sdk/lib/utils/api/items-api";
|
||||
import { getPersonsApi } from "@jellyfin/sdk/lib/utils/api/persons-api";
|
||||
import { getSearchApi } from "@jellyfin/sdk/lib/utils/api/search-api";
|
||||
import { Card } from "../../components/card/card";
|
||||
import { EpisodeCard } from "../../components/card/episodeCard";
|
||||
import { CardScroller } from "../../components/cardScroller/cardScroller";
|
||||
import { useApi } from "../../utils/store/api";
|
||||
import "./search.scss";
|
||||
import { createFileRoute } from "@tanstack/react-router";
|
||||
|
||||
const SearchPage = () => {
|
||||
const [api] = useApi((state) => [state.api]);
|
||||
export const Route = createFileRoute("/_api/search/")({
|
||||
component: SearchPage,
|
||||
});
|
||||
|
||||
function SearchPage() {
|
||||
const api = Route.useRouteContext().api;
|
||||
|
||||
const [searchTerm, setSearchTerm] = useState("");
|
||||
const searchParam = useDebounce(searchTerm, 500);
|
||||
@@ -441,6 +445,6 @@ const SearchPage = () => {
|
||||
)}
|
||||
</div>
|
||||
);
|
||||
};
|
||||
}
|
||||
|
||||
export default SearchPage;
|
||||
File renamed without changes.
@@ -16,10 +16,8 @@ import TextField from "@mui/material/TextField";
|
||||
import Typography from "@mui/material/Typography";
|
||||
import { green, red, yellow } from "@mui/material/colors";
|
||||
|
||||
import useParallax from "@/utils/hooks/useParallax";
|
||||
import { AnimatePresence, motion, useScroll } from "framer-motion";
|
||||
import useParallax from "../../utils/hooks/useParallax";
|
||||
|
||||
import { useNavigate, useParams } from "react-router-dom";
|
||||
|
||||
import { Blurhash } from "react-blurhash";
|
||||
|
||||
@@ -35,31 +33,34 @@ import { getUserLibraryApi } from "@jellyfin/sdk/lib/utils/api/user-library-api"
|
||||
|
||||
import { useQuery } from "@tanstack/react-query";
|
||||
|
||||
import { endsAt, getRuntime, getRuntimeCompact, getRuntimeMusic } from "../../utils/date/time";
|
||||
import {
|
||||
endsAt,
|
||||
getRuntime,
|
||||
getRuntimeCompact,
|
||||
getRuntimeMusic,
|
||||
} from "@/utils/date/time";
|
||||
|
||||
import { Card } from "../../components/card/card";
|
||||
import { EpisodeCard } from "../../components/card/episodeCard";
|
||||
import { CardScroller } from "../../components/cardScroller/cardScroller";
|
||||
import { Card } from "@/components/card/card";
|
||||
import { EpisodeCard } from "@/components/card/episodeCard";
|
||||
import { CardScroller } from "@/components/cardScroller/cardScroller";
|
||||
|
||||
import { ErrorNotice } from "../../components/notices/errorNotice/errorNotice";
|
||||
import { ErrorNotice } from "@/components/notices/errorNotice/errorNotice";
|
||||
import "./series.scss";
|
||||
|
||||
import { Link } from "react-router-dom";
|
||||
import { NavLink } from "react-router-dom";
|
||||
import heroBg from "../../assets/herobg.png";
|
||||
import LikeButton from "../../components/buttons/likeButton";
|
||||
import MarkPlayedButton from "../../components/buttons/markPlayedButton";
|
||||
import PlayButton from "../../components/buttons/playButton";
|
||||
import TrailerButton from "../../components/buttons/trailerButton";
|
||||
import ShowMoreText from "../../components/showMoreText";
|
||||
import { SeasonSelectorSkeleton } from "../../components/skeleton/seasonSelector";
|
||||
import TextLink from "../../components/textLink";
|
||||
import { getTypeIcon } from "../../components/utils/iconsCollection";
|
||||
import { useApi } from "../../utils/store/api";
|
||||
import { useBackdropStore } from "../../utils/store/backdrop";
|
||||
import heroBg from "@/assets/herobg.png";
|
||||
import LikeButton from "@/components/buttons/likeButton";
|
||||
import MarkPlayedButton from "@/components/buttons/markPlayedButton";
|
||||
import PlayButton from "@/components/buttons/playButton";
|
||||
import TrailerButton from "@/components/buttons/trailerButton";
|
||||
import ShowMoreText from "@/components/showMoreText";
|
||||
import { SeasonSelectorSkeleton } from "@/components/skeleton/seasonSelector";
|
||||
import { getTypeIcon } from "@/components/utils/iconsCollection";
|
||||
import { useBackdropStore } from "@/utils/store/backdrop";
|
||||
|
||||
import IconLink from "../../components/iconLink";
|
||||
import EpisodeSkeleton from "../../components/skeleton/episode";
|
||||
import IconLink from "@/components/iconLink";
|
||||
import EpisodeSkeleton from "@/components/skeleton/episode";
|
||||
import { createFileRoute } from "@tanstack/react-router";
|
||||
import { Link } from "@tanstack/react-router";
|
||||
|
||||
function TabPanel(props) {
|
||||
const { children, value, index, ...other } = props;
|
||||
@@ -87,14 +88,18 @@ TabPanel.propTypes = {
|
||||
const getEpisodeDateString = (date: Date) => {
|
||||
const formatter = new Intl.DateTimeFormat(navigator.language ?? "en-US", {
|
||||
dateStyle: "full",
|
||||
})
|
||||
});
|
||||
return formatter.format(date).toString();
|
||||
}
|
||||
};
|
||||
|
||||
const SeriesTitlePage = () => {
|
||||
const { id } = useParams();
|
||||
export const Route = createFileRoute("/_api/series/$id")({
|
||||
component: SeriesTitlePage,
|
||||
});
|
||||
|
||||
const [api] = useApi((state) => [state.api]);
|
||||
function SeriesTitlePage() {
|
||||
const { id } = Route.useParams();
|
||||
|
||||
const api = Route.useRouteContext().api;
|
||||
|
||||
const user = useQuery({
|
||||
queryKey: ["user"],
|
||||
@@ -293,7 +298,7 @@ const SeriesTitlePage = () => {
|
||||
}),
|
||||
currentSeasonItem.data.Id,
|
||||
);
|
||||
setBackdropImageLoaded(false)
|
||||
setBackdropImageLoaded(false);
|
||||
} else if (item.isSuccess && item.data?.BackdropImageTags?.length > 0) {
|
||||
sessionStorage.setItem(
|
||||
`backdrop-${item.data?.Id}`,
|
||||
@@ -313,7 +318,7 @@ const SeriesTitlePage = () => {
|
||||
}),
|
||||
item.data.Id,
|
||||
);
|
||||
setBackdropImageLoaded(false)
|
||||
setBackdropImageLoaded(false);
|
||||
}
|
||||
}, [currentSeasonItem.dataUpdatedAt]);
|
||||
|
||||
@@ -643,10 +648,13 @@ const SeriesTitlePage = () => {
|
||||
</Typography>
|
||||
<div className="item-detail-cast-grid">
|
||||
{actors.map((actor) => (
|
||||
<NavLink
|
||||
<Link
|
||||
className="item-detail-cast-card"
|
||||
key={actor.Id}
|
||||
to={`/person/${actor.Id}`}
|
||||
to={`/person/$id`}
|
||||
params={{
|
||||
id: actor.Id,
|
||||
}}
|
||||
>
|
||||
{actor.PrimaryImageTag ? (
|
||||
<img
|
||||
@@ -676,7 +684,7 @@ const SeriesTitlePage = () => {
|
||||
{actor.Role}
|
||||
</Typography>
|
||||
</div>
|
||||
</NavLink>
|
||||
</Link>
|
||||
))}
|
||||
</div>
|
||||
</div>
|
||||
@@ -688,10 +696,13 @@ const SeriesTitlePage = () => {
|
||||
</Typography>
|
||||
<div className="item-detail-cast-grid">
|
||||
{writers.map((actor) => (
|
||||
<NavLink
|
||||
<Link
|
||||
className="item-detail-cast-card"
|
||||
key={actor.Id}
|
||||
to={`/person/${actor.Id}`}
|
||||
to={`/person/$id`}
|
||||
params={{
|
||||
id: actor.Id,
|
||||
}}
|
||||
>
|
||||
{actor.PrimaryImageTag ? (
|
||||
<img
|
||||
@@ -721,7 +732,7 @@ const SeriesTitlePage = () => {
|
||||
{actor.Role}
|
||||
</Typography>
|
||||
</div>
|
||||
</NavLink>
|
||||
</Link>
|
||||
))}
|
||||
</div>
|
||||
</div>
|
||||
@@ -733,10 +744,13 @@ const SeriesTitlePage = () => {
|
||||
</Typography>
|
||||
<div className="item-detail-cast-grid">
|
||||
{directors.map((actor) => (
|
||||
<NavLink
|
||||
<Link
|
||||
className="item-detail-cast-card"
|
||||
to={`/person/${actor.Id}`}
|
||||
key={actor.Id}
|
||||
to={`/person/$id`}
|
||||
params={{
|
||||
id: actor.Id,
|
||||
}}
|
||||
>
|
||||
{actor.PrimaryImageTag ? (
|
||||
<img
|
||||
@@ -766,7 +780,7 @@ const SeriesTitlePage = () => {
|
||||
{actor.Role}
|
||||
</Typography>
|
||||
</div>
|
||||
</NavLink>
|
||||
</Link>
|
||||
))}
|
||||
</div>
|
||||
</div>
|
||||
@@ -778,10 +792,13 @@ const SeriesTitlePage = () => {
|
||||
</Typography>
|
||||
<div className="item-detail-cast-grid">
|
||||
{producers.map((actor) => (
|
||||
<NavLink
|
||||
<Link
|
||||
className="item-detail-cast-card"
|
||||
key={actor.Id}
|
||||
to={`/person/${actor.Id}`}
|
||||
to={`/person/$id`}
|
||||
params={{
|
||||
id: actor.Id,
|
||||
}}
|
||||
>
|
||||
{actor.PrimaryImageTag ? (
|
||||
<img
|
||||
@@ -811,7 +828,7 @@ const SeriesTitlePage = () => {
|
||||
{actor.Role}
|
||||
</Typography>
|
||||
</div>
|
||||
</NavLink>
|
||||
</Link>
|
||||
))}
|
||||
</div>
|
||||
</div>
|
||||
@@ -1187,6 +1204,6 @@ const SeriesTitlePage = () => {
|
||||
if (item.isError || similarItems.isError) {
|
||||
return <ErrorNotice />;
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
export default SeriesTitlePage;
|
||||
File renamed without changes.
@@ -1,30 +0,0 @@
|
||||
|
||||
.about {
|
||||
display: grid;
|
||||
grid-template-columns: 1fr 1fr;
|
||||
padding: 4em;
|
||||
align-items: start;
|
||||
&-section {
|
||||
background: $clr-background-dark;
|
||||
padding: 1em;
|
||||
border-radius: 12px;
|
||||
&.monospace * {
|
||||
font-family: "JetBrains Mono Variable" !important;
|
||||
}
|
||||
}
|
||||
&-logo {
|
||||
max-width: 50vw;
|
||||
height: 5em;
|
||||
object-fit: contain;
|
||||
object-position: center;
|
||||
margin-bottom: 1em !important;
|
||||
border-bottom: 1.4px solid rgb(255 255 255 / 0.05);
|
||||
}
|
||||
&-grid {
|
||||
display: grid;
|
||||
grid-template-columns: 1fr 1fr;
|
||||
width: 100%;
|
||||
padding: 0.5em 0;
|
||||
gap: 1em;
|
||||
}
|
||||
}
|
||||
@@ -1,153 +0,0 @@
|
||||
import CircularProgress from "@mui/material/CircularProgress";
|
||||
import Stack from "@mui/material/Stack";
|
||||
import Typography from "@mui/material/Typography";
|
||||
import React, { useEffect } from "react";
|
||||
|
||||
import logo from "../../assets/logo.svg";
|
||||
|
||||
import { useQuery } from "@tanstack/react-query";
|
||||
|
||||
import { getSystemApi } from "@jellyfin/sdk/lib/utils/api/system-api";
|
||||
|
||||
import { useApi } from "../../utils/store/api";
|
||||
import { useBackdropStore } from "../../utils/store/backdrop";
|
||||
import { useCentralStore } from "../../utils/store/central";
|
||||
import "./about.scss";
|
||||
|
||||
const About = () => {
|
||||
const [api] = useApi((state) => [state.api]);
|
||||
const systemInfo = useQuery({
|
||||
queryKey: ["about", "systemInfo"],
|
||||
queryFn: async () => {
|
||||
const result = await getSystemApi(api).getSystemInfo();
|
||||
return result.data;
|
||||
},
|
||||
enabled: Boolean(api),
|
||||
});
|
||||
|
||||
const [setBackdrop] = useBackdropStore((state) => [state.setBackdrop]);
|
||||
const [applicationVersion] = useCentralStore((state) => [
|
||||
state.clientVersion,
|
||||
]);
|
||||
|
||||
useEffect(() => {
|
||||
setBackdrop("", "");
|
||||
});
|
||||
if (systemInfo.isPending) {
|
||||
return (
|
||||
<div
|
||||
style={{
|
||||
position: "fixed",
|
||||
top: "50%",
|
||||
left: "50%",
|
||||
transform: "translate(-50%, -50%)",
|
||||
}}
|
||||
>
|
||||
<CircularProgress size={72} thickness={1.4} />
|
||||
</div>
|
||||
);
|
||||
}
|
||||
return (
|
||||
<main className="scrollY about">
|
||||
<Stack
|
||||
alignItems="center"
|
||||
justifyContent="center"
|
||||
className="about-section monospace"
|
||||
width="75%"
|
||||
>
|
||||
<a
|
||||
href="https://github.com/prayag17/JellyPlayer"
|
||||
className="about-logo"
|
||||
target="_blank"
|
||||
rel="noreferrer"
|
||||
>
|
||||
<img alt="JellyPlayer" width="100%" height="100%" src={logo} />
|
||||
</a>
|
||||
<div
|
||||
style={{
|
||||
display: "flex",
|
||||
flexDirection: "column",
|
||||
opacity: 0.9,
|
||||
}}
|
||||
>
|
||||
<div className="about-grid">
|
||||
<Typography variant="h6" fontWeight={300}>
|
||||
Server
|
||||
</Typography>
|
||||
<Typography
|
||||
variant="h6"
|
||||
fontWeight={300}
|
||||
sx={{
|
||||
opacity: 0.7,
|
||||
}}
|
||||
>
|
||||
{systemInfo.data.ServerName}
|
||||
</Typography>
|
||||
</div>
|
||||
|
||||
<div className="about-grid">
|
||||
<Typography variant="h6" fontWeight={300}>
|
||||
Server Version
|
||||
</Typography>
|
||||
<Typography
|
||||
variant="h6"
|
||||
fontWeight={300}
|
||||
sx={{
|
||||
opacity: 0.7,
|
||||
}}
|
||||
>
|
||||
{systemInfo.data.Version}
|
||||
</Typography>
|
||||
</div>
|
||||
|
||||
<div className="about-grid">
|
||||
<Typography variant="h6" fontWeight={300}>
|
||||
Operating System
|
||||
</Typography>
|
||||
<Typography
|
||||
variant="h6"
|
||||
fontWeight={300}
|
||||
sx={{
|
||||
opacity: 0.7,
|
||||
}}
|
||||
>
|
||||
{systemInfo.data.OperatingSystemDisplayName}
|
||||
</Typography>
|
||||
</div>
|
||||
|
||||
<div className="about-grid">
|
||||
<Typography variant="h6" fontWeight={300}>
|
||||
Architecture
|
||||
</Typography>
|
||||
<Typography
|
||||
variant="h6"
|
||||
fontWeight={300}
|
||||
sx={{
|
||||
opacity: 0.7,
|
||||
}}
|
||||
>
|
||||
{systemInfo.data.SystemArchitecture}
|
||||
</Typography>
|
||||
</div>
|
||||
|
||||
<div className="about-grid">
|
||||
<Typography variant="h6" fontWeight={300}>
|
||||
JellyPlayer Version
|
||||
</Typography>
|
||||
<Typography
|
||||
variant="h6"
|
||||
fontWeight={300}
|
||||
sx={{
|
||||
opacity: 0.7,
|
||||
}}
|
||||
>
|
||||
{applicationVersion}
|
||||
</Typography>
|
||||
</div>
|
||||
</div>
|
||||
</Stack>
|
||||
</main>
|
||||
);
|
||||
};
|
||||
|
||||
export default About;
|
||||
@@ -0,0 +1,107 @@
|
||||
import {
|
||||
type ServerInfo,
|
||||
getAllServers,
|
||||
getDefaultServer,
|
||||
getServer,
|
||||
} from "@/utils/storage/servers";
|
||||
import { UserStore, delUser, getUser } from "@/utils/storage/user";
|
||||
import { useApiInContext } from "@/utils/store/api";
|
||||
import { setAppReady, useCentralStore } from "@/utils/store/central";
|
||||
import { getSystemApi } from "@jellyfin/sdk/lib/utils/api/system-api";
|
||||
import { getUserApi } from "@jellyfin/sdk/lib/utils/api/user-api";
|
||||
import {
|
||||
Button,
|
||||
ButtonGroup,
|
||||
CircularProgress,
|
||||
Typography,
|
||||
} from "@mui/material";
|
||||
import { Outlet, createFileRoute, useNavigate } from "@tanstack/react-router";
|
||||
import axios from "axios";
|
||||
import { AnimatePresence, motion } from "framer-motion";
|
||||
import * as React from "react";
|
||||
import Markdown from "react-markdown";
|
||||
import remarkGfm from "remark-gfm";
|
||||
|
||||
type LoaderData = {
|
||||
serversOnDisk: ServerInfo[];
|
||||
currentServer: ServerInfo | undefined;
|
||||
userOnDisk: { Name: string; AccessToken: string } | null;
|
||||
};
|
||||
|
||||
export const Route = createFileRoute("/")({
|
||||
component: Index,
|
||||
errorComponent: (error) => {
|
||||
console.error(error.error);
|
||||
},
|
||||
beforeLoad: async ({ context, navigate }) => {
|
||||
const api = context.api;
|
||||
const serversOnDisk = await getAllServers();
|
||||
const currentServerId = await getDefaultServer();
|
||||
const currentServer = await getServer(currentServerId);
|
||||
const userOnDisk = await getUser();
|
||||
const createApi = context.createApi;
|
||||
|
||||
if (serversOnDisk.length > 0) {
|
||||
if (currentServer) {
|
||||
// setStatus(
|
||||
// `Server found!
|
||||
// Checking server status...`,
|
||||
// );
|
||||
// setIsError(false);
|
||||
const pingServer = async () => {
|
||||
const result = (
|
||||
await axios.get(`${currentServer.address}/System/Ping`)
|
||||
).data;
|
||||
return result === "Jellyfin Server";
|
||||
};
|
||||
pingServer()
|
||||
.then(async (isOnline) => {
|
||||
if (isOnline) {
|
||||
// setStatus("Server online!");
|
||||
// setIsError(false);
|
||||
|
||||
createApi(currentServer.address, undefined);
|
||||
|
||||
if (userOnDisk) {
|
||||
// setStatus(
|
||||
// `User found!
|
||||
// Trying to authenticate user...`,
|
||||
// );
|
||||
|
||||
createApi(currentServer.address, userOnDisk.AccessToken);
|
||||
|
||||
// const api = useApiInContext((s) => s.api);
|
||||
try {
|
||||
console.log();
|
||||
await getUserApi(api).getCurrentUser();
|
||||
} catch (err) {
|
||||
console.error(err);
|
||||
// setStatus("Unable to authenticate.");
|
||||
// setIsError(true);
|
||||
// setIsAuthError(true);
|
||||
}
|
||||
} else {
|
||||
navigate({ to: "/login" });
|
||||
}
|
||||
} else {
|
||||
// setStatus("Unable to reach server");
|
||||
// setIsError(false);
|
||||
}
|
||||
})
|
||||
.catch((error) => {
|
||||
// setStatus("Unable to reach server");
|
||||
// setIsError(true);
|
||||
console.error(error);
|
||||
});
|
||||
} else {
|
||||
// setStatus("No server found.");
|
||||
// setIsError(false);
|
||||
navigate({ to: "/setup/server/list" });
|
||||
}
|
||||
}
|
||||
},
|
||||
});
|
||||
|
||||
function Index() {
|
||||
return <h1>Loading...</h1>;
|
||||
}
|
||||
@@ -1,974 +0,0 @@
|
||||
import { useMutation, useQuery } from "@tanstack/react-query";
|
||||
import React, { useLayoutEffect, useState } from "react";
|
||||
import { useNavigate, useParams } from "react-router-dom";
|
||||
import { EventEmitter as event } from "../../eventEmitter.js";
|
||||
|
||||
import { saveUser } from "../../utils/storage/user";
|
||||
|
||||
import LoadingButton from "@mui/lab/LoadingButton";
|
||||
import {
|
||||
Dialog,
|
||||
DialogActions,
|
||||
DialogContent,
|
||||
DialogContentText,
|
||||
Grid,
|
||||
OutlinedInput,
|
||||
Paper,
|
||||
Tooltip,
|
||||
Typography,
|
||||
} from "@mui/material";
|
||||
import Button from "@mui/material/Button";
|
||||
import Checkbox from "@mui/material/Checkbox";
|
||||
import CircularProgress from "@mui/material/CircularProgress";
|
||||
import Container from "@mui/material/Container";
|
||||
import FormControl from "@mui/material/FormControl";
|
||||
import FormControlLabel from "@mui/material/FormControlLabel";
|
||||
import FormGroup from "@mui/material/FormGroup";
|
||||
import IconButton from "@mui/material/IconButton";
|
||||
import InputAdornment from "@mui/material/InputAdornment";
|
||||
import InputLabel from "@mui/material/InputLabel";
|
||||
import LinearProgress from "@mui/material/LinearProgress";
|
||||
|
||||
import { useSnackbar } from "notistack";
|
||||
|
||||
import { AppBarBackOnly } from "../../components/appBar/backOnly.jsx";
|
||||
import { AvatarImage } from "../../components/avatar/avatar.jsx";
|
||||
import { Card } from "../../components/card/card";
|
||||
|
||||
import { getBrandingApi } from "@jellyfin/sdk/lib/utils/api/branding-api";
|
||||
import { getQuickConnectApi } from "@jellyfin/sdk/lib/utils/api/quick-connect-api";
|
||||
import { getUserApi } from "@jellyfin/sdk/lib/utils/api/user-api";
|
||||
|
||||
import { ErrorNotice } from "../../components/notices/errorNotice/errorNotice.jsx";
|
||||
import { createApi, useApi } from "../../utils/store/api";
|
||||
import "./login.scss";
|
||||
|
||||
import { blue } from "@mui/material/colors";
|
||||
import { setBackdrop } from "../../utils/store/backdrop.js";
|
||||
|
||||
export const LoginRoute = () => {
|
||||
const navigate = useNavigate();
|
||||
const [api] = useApi((state) => [state.api]);
|
||||
|
||||
const usersList = useQuery({
|
||||
queryKey: ["public-users"],
|
||||
queryFn: async () => {
|
||||
const result = await getUserApi(api).getPublicUsers();
|
||||
return result.data;
|
||||
},
|
||||
enabled: Boolean(api),
|
||||
});
|
||||
|
||||
if (usersList.isSuccess && !usersList.isFetching) {
|
||||
if (usersList.data.length > 0) {
|
||||
navigate("/login/users");
|
||||
} else {
|
||||
navigate("/login/manual");
|
||||
}
|
||||
}
|
||||
|
||||
return (
|
||||
<div
|
||||
style={{
|
||||
position: "fixed",
|
||||
top: "50%",
|
||||
left: "50%",
|
||||
transform: "translate(-50%, -50%)",
|
||||
}}
|
||||
>
|
||||
<CircularProgress size={72} thickness={1.4} />
|
||||
</div>
|
||||
);
|
||||
};
|
||||
|
||||
export const LoginWithImage = () => {
|
||||
const { userName, userId } = useParams();
|
||||
|
||||
const [api] = useApi((state) => [state.api]);
|
||||
|
||||
const [password, setPassword] = useState({
|
||||
showpass: false,
|
||||
});
|
||||
const [loading, setLoading] = useState(false);
|
||||
const [rememberMe, setRememberMe] = useState(true);
|
||||
|
||||
const navigate = useNavigate();
|
||||
|
||||
const { enqueueSnackbar } = useSnackbar();
|
||||
|
||||
const handlePassword = (prop) => (event) => {
|
||||
setPassword({
|
||||
...password,
|
||||
[prop]: event.target.value,
|
||||
});
|
||||
};
|
||||
|
||||
const handleShowPassword = () => {
|
||||
setPassword({
|
||||
...password,
|
||||
showpass: !password.showpass,
|
||||
});
|
||||
};
|
||||
|
||||
const authUser = async () => {
|
||||
try {
|
||||
const auth = await api.authenticateUserByName(
|
||||
userName,
|
||||
password.password,
|
||||
);
|
||||
return auth;
|
||||
} catch (error) {
|
||||
if (error.response?.status === 500) {
|
||||
enqueueSnackbar(
|
||||
"Unable to connect to server. Please try again after some time.",
|
||||
{ variant: "error" },
|
||||
);
|
||||
} else {
|
||||
enqueueSnackbar("Incorrect Password.", { variant: "error" });
|
||||
}
|
||||
setLoading(false);
|
||||
console.error(error);
|
||||
}
|
||||
};
|
||||
|
||||
const handleLogin = async () => {
|
||||
setLoading(true);
|
||||
const user = await authUser();
|
||||
sessionStorage.setItem("accessToken", user.data.AccessToken);
|
||||
createApi(api.basePath, user.data.AccessToken);
|
||||
if (rememberMe === true) {
|
||||
await saveUser(userName, user.data.AccessToken);
|
||||
}
|
||||
setLoading(false);
|
||||
navigate("/home");
|
||||
};
|
||||
|
||||
useLayoutEffect(() => {
|
||||
setBackdrop("", "");
|
||||
}, []);
|
||||
|
||||
const handleCheckRememberMe = (event) => {
|
||||
setRememberMe(event.target.checked);
|
||||
};
|
||||
|
||||
return (
|
||||
<>
|
||||
<AppBarBackOnly />
|
||||
<div
|
||||
style={{
|
||||
height: "100vh",
|
||||
display: "flex",
|
||||
justifyContent: "center",
|
||||
alignItems: "center",
|
||||
flexDirection: "column",
|
||||
width: "30vw",
|
||||
margin: "auto",
|
||||
}}
|
||||
>
|
||||
<div
|
||||
style={{
|
||||
marginBottom: "-4em",
|
||||
boxShadow: "1em 0 hsl(256, 100%, 6%)",
|
||||
}}
|
||||
>
|
||||
<AvatarImage userId={userId} />
|
||||
</div>
|
||||
<Paper
|
||||
sx={{
|
||||
width: "100%",
|
||||
padding: "1em",
|
||||
paddingTop: "5em",
|
||||
borderRadius: "10px",
|
||||
}}
|
||||
elevation={2}
|
||||
>
|
||||
<Typography
|
||||
textAlign="center"
|
||||
variant="h5"
|
||||
sx={{ opacity: 0.8 }}
|
||||
mb={2}
|
||||
>
|
||||
Login as{" "}
|
||||
<Typography
|
||||
variant="h5"
|
||||
style={{
|
||||
display: "inline",
|
||||
}}
|
||||
fontWeight={700}
|
||||
className="gradient-text"
|
||||
>
|
||||
{userName}
|
||||
</Typography>
|
||||
</Typography>
|
||||
<FormGroup
|
||||
sx={{
|
||||
width: "100%",
|
||||
}}
|
||||
>
|
||||
<FormControl
|
||||
variant="outlined"
|
||||
style={{
|
||||
width: "100%",
|
||||
}}
|
||||
>
|
||||
<InputLabel htmlFor="user-password">Password:</InputLabel>
|
||||
<OutlinedInput
|
||||
id="user-password"
|
||||
type={password.showpass ? "text" : "password"}
|
||||
variant="outlined"
|
||||
onChange={handlePassword("password")}
|
||||
label="Password:"
|
||||
endAdornment={
|
||||
<InputAdornment position="end">
|
||||
<IconButton
|
||||
onClick={handleShowPassword}
|
||||
aria-label="toggle password visibility"
|
||||
>
|
||||
{password.showpass ? (
|
||||
<span className="material-symbols-rounded">
|
||||
visibility
|
||||
</span>
|
||||
) : (
|
||||
<span className="material-symbols-rounded">
|
||||
visibility_off
|
||||
</span>
|
||||
)}
|
||||
</IconButton>
|
||||
</InputAdornment>
|
||||
}
|
||||
/>
|
||||
</FormControl>
|
||||
<FormControlLabel
|
||||
control={
|
||||
<Checkbox
|
||||
checked={rememberMe}
|
||||
onChange={handleCheckRememberMe}
|
||||
/>
|
||||
}
|
||||
label="Remember me"
|
||||
/>
|
||||
</FormGroup>
|
||||
<LoadingButton
|
||||
variant="contained"
|
||||
endIcon={
|
||||
<span className="material-symbols-rounded">chevron_right</span>
|
||||
}
|
||||
onClick={handleLogin}
|
||||
loading={loading}
|
||||
loadingPosition="end"
|
||||
size="large"
|
||||
fullWidth
|
||||
>
|
||||
Login
|
||||
</LoadingButton>
|
||||
</Paper>
|
||||
</div>
|
||||
</>
|
||||
);
|
||||
};
|
||||
|
||||
export const UserLogin = () => {
|
||||
const navigate = useNavigate();
|
||||
|
||||
const { enqueueSnackbar } = useSnackbar();
|
||||
|
||||
const [api] = useApi((state) => [state.api]);
|
||||
|
||||
const [loading, setLoading] = useState(false);
|
||||
const [rememberMe, setRememberMe] = useState(true);
|
||||
const [quickConnectLoading, setQuickConnectLoading] = useState(-1);
|
||||
const [quickConnectCode, setQuickConnectCode] = useState("");
|
||||
|
||||
const handleCheckRememberMe = (event) => {
|
||||
setRememberMe(event.target.checked);
|
||||
};
|
||||
|
||||
const handleChangeServer = () => {
|
||||
navigate("/servers/list");
|
||||
};
|
||||
const handleManualLogin = () => {
|
||||
navigate("/login/manual");
|
||||
};
|
||||
const users = useQuery({
|
||||
queryKey: ["login", "users"],
|
||||
queryFn: async () => {
|
||||
const users = await getUserApi(api).getPublicUsers();
|
||||
return users.data;
|
||||
},
|
||||
staleTime: 0,
|
||||
});
|
||||
|
||||
const handleQuickConnect = async () => {
|
||||
setQuickConnectLoading(0);
|
||||
|
||||
const quickApi = getQuickConnectApi(api);
|
||||
|
||||
const headers = {
|
||||
"X-Emby-Authorization": `MediaBrowser Client="${api.clientInfo.name}", Device="${api.deviceInfo.name}", DeviceId="${api.deviceInfo.id}", Version="${api.clientInfo.version}"`,
|
||||
};
|
||||
|
||||
const quickConnectInitiation = await quickApi
|
||||
.initiate({
|
||||
headers,
|
||||
})
|
||||
.catch(() => ({ status: 401 }));
|
||||
|
||||
if (quickConnectInitiation.status !== 200) {
|
||||
setQuickConnectLoading(-1);
|
||||
enqueueSnackbar("Unable to use Quick Connect", {
|
||||
variant: "error",
|
||||
});
|
||||
return;
|
||||
}
|
||||
|
||||
setQuickConnectLoading(1);
|
||||
|
||||
const { Secret, Code } = quickConnectInitiation.data;
|
||||
|
||||
setQuickConnectCode(Code);
|
||||
|
||||
const interval = setInterval(async () => {
|
||||
const quickConnectCheck = await quickApi
|
||||
.connect({
|
||||
secret: Secret,
|
||||
})
|
||||
.catch(() => ({ status: 401, data: { Authenticated: false } }));
|
||||
|
||||
if (quickConnectCheck.status !== 200) {
|
||||
setQuickConnectCode("");
|
||||
enqueueSnackbar("Unable to use Quick Connect", {
|
||||
variant: "error",
|
||||
});
|
||||
|
||||
setQuickConnectLoading(-1);
|
||||
clearInterval(interval);
|
||||
return;
|
||||
}
|
||||
|
||||
if (!quickConnectCheck.data.Authenticated) {
|
||||
return;
|
||||
}
|
||||
|
||||
const auth = await getUserApi(api)
|
||||
.authenticateWithQuickConnect({
|
||||
quickConnectDto: {
|
||||
Secret: Secret,
|
||||
},
|
||||
})
|
||||
.catch(() => ({ status: 401 }));
|
||||
|
||||
api.accessToken = auth.data.AccessToken;
|
||||
|
||||
clearInterval(interval);
|
||||
|
||||
if (auth.status !== 200) {
|
||||
enqueueSnackbar("Unable to use Quick Connect", {
|
||||
variant: "error",
|
||||
});
|
||||
setQuickConnectLoading(-1);
|
||||
return;
|
||||
}
|
||||
|
||||
sessionStorage.setItem("accessToken", auth.data.AccessToken);
|
||||
createApi(api.basePath, auth.data.AccessToken);
|
||||
|
||||
if (rememberMe === true) {
|
||||
await saveUser(auth.data.User.Name, auth.data.AccessToken);
|
||||
}
|
||||
|
||||
setQuickConnectLoading(-1);
|
||||
enqueueSnackbar(`Logged in as ${auth.data.User.Name}!`, {
|
||||
variant: "success",
|
||||
});
|
||||
navigate("/home");
|
||||
}, 1000);
|
||||
|
||||
setLoading(false);
|
||||
};
|
||||
|
||||
useLayoutEffect(() => {
|
||||
setBackdrop("", "");
|
||||
}, []);
|
||||
|
||||
if (users.isPending) {
|
||||
return <LinearProgress />;
|
||||
}
|
||||
|
||||
if (users.isSuccess) {
|
||||
return (
|
||||
<>
|
||||
<AppBarBackOnly />
|
||||
<Container
|
||||
maxWidth="md"
|
||||
sx={{
|
||||
height: "100vh",
|
||||
display: "flex",
|
||||
flexDirection: "column",
|
||||
justifyContent: "center",
|
||||
alignItems: "center",
|
||||
}}
|
||||
>
|
||||
<Typography variant="h3" mb={2}>
|
||||
Users
|
||||
</Typography>
|
||||
|
||||
<Grid
|
||||
container
|
||||
columns={{
|
||||
xs: 2,
|
||||
sm: 3,
|
||||
md: 4,
|
||||
}}
|
||||
wrap="nowrap"
|
||||
alignItems="center"
|
||||
overflow="auto"
|
||||
width="100%"
|
||||
mb={3}
|
||||
paddingBottom={2}
|
||||
className="roundedScrollbar"
|
||||
>
|
||||
{users.data.map((item, index) => {
|
||||
return (
|
||||
<Grid
|
||||
key={item.Id}
|
||||
flexShrink={0}
|
||||
flexGrow={1}
|
||||
xs={1}
|
||||
sm={1}
|
||||
md={1}
|
||||
>
|
||||
<Card
|
||||
cardTitle={item.Name}
|
||||
item={item}
|
||||
disableOverlay
|
||||
itemType="User"
|
||||
cardType="square"
|
||||
onClick={() =>
|
||||
navigate(`/login/withImg/${item.Name}/${item.Id}/`)
|
||||
}
|
||||
overrideIcon="User"
|
||||
imageType="Primary"
|
||||
/>
|
||||
</Grid>
|
||||
);
|
||||
})}
|
||||
</Grid>
|
||||
|
||||
<div className="buttons">
|
||||
<Button
|
||||
color="secondary"
|
||||
variant="contained"
|
||||
className="userEventButton"
|
||||
onClick={handleChangeServer}
|
||||
>
|
||||
Change Server
|
||||
</Button>
|
||||
<LoadingButton
|
||||
onClick={handleQuickConnect}
|
||||
variant="contained"
|
||||
className="userEventButton"
|
||||
sx={{ width: "100%" }}
|
||||
loading={quickConnectLoading === 1}
|
||||
size="large"
|
||||
>
|
||||
Quick Connect
|
||||
</LoadingButton>
|
||||
<Button
|
||||
variant="contained"
|
||||
className="userEventButton"
|
||||
onClick={handleManualLogin}
|
||||
size="small"
|
||||
>
|
||||
Manual Login
|
||||
</Button>
|
||||
</div>
|
||||
|
||||
<Dialog open={Boolean(quickConnectCode)} fullWidth maxWidth="xs">
|
||||
<DialogContent
|
||||
style={{
|
||||
display: "flex",
|
||||
flexDirection: "column",
|
||||
alignItems: "center",
|
||||
}}
|
||||
>
|
||||
<Typography
|
||||
variant="h5"
|
||||
mb={2}
|
||||
style={{
|
||||
width: "100%",
|
||||
}}
|
||||
>
|
||||
Quick Connect Code:
|
||||
</Typography>
|
||||
<DialogContentText>
|
||||
Use this code in the Quick Connect tab in your server to login.
|
||||
</DialogContentText>
|
||||
<div
|
||||
className="flex flex-row"
|
||||
style={{ gap: "1em", alignItems: "center", marginTop: "1em" }}
|
||||
>
|
||||
<Tooltip title="Click to copy" arrow placement="top">
|
||||
<Typography
|
||||
variant="h3"
|
||||
color="textPrimary"
|
||||
textAlign="center"
|
||||
sx={{
|
||||
background: "rgb(255 255 255 / 0.1)",
|
||||
width: "fit-content",
|
||||
padding: "0.4em",
|
||||
borderRadius: "10px",
|
||||
cursor: "pointer",
|
||||
}}
|
||||
onClick={(e) => {
|
||||
navigator.clipboard.writeText(quickConnectCode);
|
||||
enqueueSnackbar("Quick Connect Code copied!", {
|
||||
variant: "info",
|
||||
key: "copiedText",
|
||||
});
|
||||
}}
|
||||
>
|
||||
{quickConnectCode}
|
||||
</Typography>
|
||||
</Tooltip>
|
||||
</div>
|
||||
</DialogContent>
|
||||
<DialogActions
|
||||
className="flex flex-row"
|
||||
sx={{
|
||||
padding: "0em 1em 1em 1em",
|
||||
justifyContent: "space-between",
|
||||
}}
|
||||
>
|
||||
<FormControlLabel
|
||||
control={
|
||||
<Checkbox
|
||||
checked={rememberMe}
|
||||
onChange={handleCheckRememberMe}
|
||||
/>
|
||||
}
|
||||
label="Remember device"
|
||||
/>
|
||||
<Button
|
||||
variant="contained"
|
||||
onClick={() => {
|
||||
setQuickConnectCode("");
|
||||
setQuickConnectLoading(-1);
|
||||
}}
|
||||
>
|
||||
Close
|
||||
</Button>
|
||||
</DialogActions>
|
||||
</Dialog>
|
||||
</Container>
|
||||
</>
|
||||
);
|
||||
}
|
||||
if (users.isError) {
|
||||
return <ErrorNotice />;
|
||||
}
|
||||
};
|
||||
|
||||
export const UserLoginManual = () => {
|
||||
const [loading, setLoading] = useState(false);
|
||||
const [quickConnectLoading, setQuickConnectLoading] = useState(-1);
|
||||
const [quickConnectCode, setQuickConnectCode] = useState("");
|
||||
const [rememberMe, setRememberMe] = useState(true);
|
||||
const [api] = useApi((state) => [state.api]);
|
||||
|
||||
const navigate = useNavigate();
|
||||
const { enqueueSnackbar } = useSnackbar();
|
||||
|
||||
const [password, setPassword] = useState({
|
||||
showpass: false,
|
||||
});
|
||||
const [userName, setUserName] = useState("");
|
||||
|
||||
const server = useQuery({
|
||||
queryKey: ["login, manual", "serverInfo"],
|
||||
queryFn: async () => {
|
||||
const result = await getBrandingApi(api).getBrandingOptions();
|
||||
return result.data;
|
||||
},
|
||||
networkMode: "always",
|
||||
});
|
||||
|
||||
const handleUsername = (event) => {
|
||||
setUserName(event.target.value);
|
||||
};
|
||||
|
||||
const handlePassword = (prop) => (event) => {
|
||||
setPassword({
|
||||
...password,
|
||||
[prop]: event.target.value,
|
||||
});
|
||||
};
|
||||
|
||||
const handleShowPassword = () => {
|
||||
setPassword({
|
||||
...password,
|
||||
showpass: !password.showpass,
|
||||
});
|
||||
};
|
||||
|
||||
const authUser = async () => {
|
||||
try {
|
||||
const auth = await api.authenticateUserByName(
|
||||
userName,
|
||||
password.password,
|
||||
);
|
||||
return auth;
|
||||
} catch (error) {
|
||||
enqueueSnackbar("Incorrect Username or Password!", {
|
||||
variant: "error",
|
||||
});
|
||||
setLoading(false);
|
||||
console.error(error);
|
||||
}
|
||||
};
|
||||
|
||||
const handleLogin = async () => {
|
||||
setLoading(true);
|
||||
const user = await authUser();
|
||||
sessionStorage.setItem("accessToken", user.data.AccessToken);
|
||||
createApi(api.basePath, user.data.AccessToken);
|
||||
if (rememberMe === true) {
|
||||
await saveUser(userName, user.data.AccessToken);
|
||||
}
|
||||
setLoading(false);
|
||||
navigate("/home");
|
||||
};
|
||||
|
||||
const handleCheckRememberMe = (event) => {
|
||||
setRememberMe(event.target.checked);
|
||||
};
|
||||
|
||||
const handleQuickConnect = async () => {
|
||||
setQuickConnectLoading(0);
|
||||
|
||||
const quickApi = getQuickConnectApi(api);
|
||||
|
||||
const headers = {
|
||||
"X-Emby-Authorization": `MediaBrowser Client="${api.clientInfo.name}", Device="${api.deviceInfo.name}", DeviceId="${api.deviceInfo.id}", Version="${api.clientInfo.version}"`,
|
||||
};
|
||||
|
||||
const quickConnectInitiation = await quickApi
|
||||
.initiate({
|
||||
headers,
|
||||
})
|
||||
.catch(() => ({ status: 401 }));
|
||||
|
||||
if (quickConnectInitiation.status !== 200) {
|
||||
setQuickConnectCode("");
|
||||
setQuickConnectLoading(-1);
|
||||
enqueueSnackbar("Unable to use Quick Connect", {
|
||||
variant: "error",
|
||||
});
|
||||
return;
|
||||
}
|
||||
|
||||
setQuickConnectLoading(1);
|
||||
|
||||
const { Secret, Code } = quickConnectInitiation.data;
|
||||
|
||||
setQuickConnectCode(Code);
|
||||
|
||||
const interval = setInterval(async () => {
|
||||
const quickConnectCheck = await quickApi
|
||||
.connect({
|
||||
secret: Secret,
|
||||
})
|
||||
.catch(() => ({ status: 401, data: { Authenticated: false } }));
|
||||
|
||||
if (quickConnectCheck.status !== 200) {
|
||||
enqueueSnackbar("Unable to use Quick Connect", {
|
||||
variant: "error",
|
||||
});
|
||||
|
||||
setQuickConnectLoading(-1);
|
||||
clearInterval(interval);
|
||||
return;
|
||||
}
|
||||
|
||||
if (!quickConnectCheck.data.Authenticated) {
|
||||
return;
|
||||
}
|
||||
|
||||
const auth = await getUserApi(api)
|
||||
.authenticateWithQuickConnect({
|
||||
quickConnectDto: {
|
||||
Secret: Secret,
|
||||
},
|
||||
})
|
||||
.catch(() => ({ status: 401 }));
|
||||
|
||||
api.accessToken = auth.data.AccessToken;
|
||||
|
||||
clearInterval(interval);
|
||||
|
||||
if (auth.status !== 200) {
|
||||
enqueueSnackbar("Unable to use Quick Connect", {
|
||||
variant: "error",
|
||||
});
|
||||
setQuickConnectLoading(-1);
|
||||
return;
|
||||
}
|
||||
|
||||
sessionStorage.setItem("accessToken", auth.data.AccessToken);
|
||||
createApi(api.basePath, auth.data.AccessToken);
|
||||
|
||||
if (rememberMe === true) {
|
||||
await saveUser(userName, auth.data.AccessToken);
|
||||
}
|
||||
|
||||
setQuickConnectLoading(-1);
|
||||
enqueueSnackbar(`Logged in as ${auth.data.User.Name}!`, {
|
||||
variant: "success",
|
||||
});
|
||||
navigate("/home");
|
||||
}, 1000);
|
||||
|
||||
setLoading(false);
|
||||
};
|
||||
|
||||
useLayoutEffect(() => {
|
||||
setBackdrop("", "");
|
||||
}, []);
|
||||
|
||||
return (
|
||||
<>
|
||||
{server.isPending && <LinearProgress />}
|
||||
<AppBarBackOnly />
|
||||
<Container
|
||||
maxWidth="xs"
|
||||
sx={{
|
||||
height: "100vh",
|
||||
display: "flex",
|
||||
justifyContent: "center",
|
||||
alignItems: "center",
|
||||
}}
|
||||
>
|
||||
<Grid
|
||||
container
|
||||
spacing={2}
|
||||
direction="column"
|
||||
justifyContent="center"
|
||||
alignItems="center"
|
||||
sx={{
|
||||
opacity: server.isPending ? 0 : 1,
|
||||
transition: "opacity 200ms",
|
||||
width: "100%",
|
||||
}}
|
||||
>
|
||||
<Grid sx={{ marginBottom: "1em" }}>
|
||||
<Typography variant="h3" color="textPrimary">
|
||||
Login
|
||||
</Typography>
|
||||
</Grid>
|
||||
<Grid sx={{ width: "100%", mb: 1 }}>
|
||||
<FormControl sx={{ width: "100%" }} variant="outlined">
|
||||
<InputLabel htmlFor="user-name">Username:</InputLabel>
|
||||
<OutlinedInput
|
||||
fullWidth
|
||||
id="user-name"
|
||||
type="text"
|
||||
variant="outlined"
|
||||
label="Username:"
|
||||
onChange={handleUsername}
|
||||
/>
|
||||
</FormControl>
|
||||
</Grid>
|
||||
<Grid sx={{ width: "100%" }}>
|
||||
<FormGroup>
|
||||
<FormControl sx={{ width: "100%" }} variant="outlined">
|
||||
<InputLabel htmlFor="user-password">Password:</InputLabel>
|
||||
<OutlinedInput
|
||||
fullWidth
|
||||
id="user-password"
|
||||
type={password.showpass ? "text" : "password"}
|
||||
variant="outlined"
|
||||
onChange={handlePassword("password")}
|
||||
onKeyUp={(event) => {
|
||||
if (event.key === "Enter") {
|
||||
handleLogin();
|
||||
}
|
||||
}}
|
||||
label="Password:"
|
||||
endAdornment={
|
||||
<InputAdornment position="end">
|
||||
<IconButton
|
||||
onClick={handleShowPassword}
|
||||
aria-label="toggle password visibility"
|
||||
>
|
||||
{password.showpass ? (
|
||||
<span className="material-symbols-rounded">
|
||||
visibility
|
||||
</span>
|
||||
) : (
|
||||
<span className="material-symbols-rounded">
|
||||
visibility_off
|
||||
</span>
|
||||
)}
|
||||
</IconButton>
|
||||
</InputAdornment>
|
||||
}
|
||||
/>
|
||||
</FormControl>
|
||||
<FormControlLabel
|
||||
control={
|
||||
<Checkbox
|
||||
checked={rememberMe}
|
||||
onChange={handleCheckRememberMe}
|
||||
/>
|
||||
}
|
||||
label="Remember me"
|
||||
/>
|
||||
</FormGroup>
|
||||
</Grid>
|
||||
<div
|
||||
className="flex flex-column"
|
||||
style={{ width: "100%", gap: "0.4em" }}
|
||||
>
|
||||
<LoadingButton
|
||||
variant="contained"
|
||||
endIcon={
|
||||
<span className="material-symbols-rounded">chevron_right</span>
|
||||
}
|
||||
onClick={handleLogin}
|
||||
loading={loading}
|
||||
loadingPosition="end"
|
||||
size="large"
|
||||
sx={{ width: "100%" }}
|
||||
>
|
||||
Login
|
||||
</LoadingButton>
|
||||
<LoadingButton
|
||||
onClick={handleQuickConnect}
|
||||
variant="contained"
|
||||
className="userEventButton"
|
||||
sx={{ width: "100%" }}
|
||||
loading={quickConnectLoading === 1}
|
||||
// size="large"
|
||||
>
|
||||
Quick Connect
|
||||
</LoadingButton>
|
||||
<Button
|
||||
color="secondary"
|
||||
variant="contained"
|
||||
className="userEventButton"
|
||||
// size="large"
|
||||
sx={{ width: "100%" }}
|
||||
onClick={() => navigate("/servers/list")}
|
||||
>
|
||||
Change Server
|
||||
</Button>
|
||||
</div>
|
||||
<Dialog open={Boolean(quickConnectCode)} fullWidth maxWidth="xs">
|
||||
<DialogContent
|
||||
style={{
|
||||
display: "flex",
|
||||
flexDirection: "column",
|
||||
alignItems: "center",
|
||||
}}
|
||||
>
|
||||
<Typography
|
||||
variant="h5"
|
||||
mb={2}
|
||||
style={{
|
||||
width: "100%",
|
||||
}}
|
||||
>
|
||||
Quick Connect Code:
|
||||
</Typography>
|
||||
<DialogContentText>
|
||||
Use this code in the Quick Connect tab in your server to login.
|
||||
</DialogContentText>
|
||||
<div
|
||||
className="flex flex-row"
|
||||
style={{ gap: "1em", alignItems: "center", marginTop: "1em" }}
|
||||
>
|
||||
<Tooltip title="Click to copy" arrow placement="top">
|
||||
<Typography
|
||||
variant="h3"
|
||||
color="textPrimary"
|
||||
textAlign="center"
|
||||
sx={{
|
||||
background: "rgb(255 255 255 / 0.1)",
|
||||
width: "fit-content",
|
||||
padding: "0.4em",
|
||||
borderRadius: "10px",
|
||||
cursor: "pointer",
|
||||
}}
|
||||
onClick={(e) => {
|
||||
navigator.clipboard.writeText(quickConnectCode);
|
||||
enqueueSnackbar("Quick Connect Code copied!", {
|
||||
variant: "info",
|
||||
key: "copiedText",
|
||||
});
|
||||
}}
|
||||
>
|
||||
{quickConnectCode}
|
||||
</Typography>
|
||||
</Tooltip>
|
||||
</div>
|
||||
</DialogContent>
|
||||
<DialogActions
|
||||
className="flex flex-row"
|
||||
sx={{
|
||||
padding: "0em 1em 1em 1em",
|
||||
justifyContent: "space-between",
|
||||
}}
|
||||
>
|
||||
<FormControlLabel
|
||||
control={
|
||||
<Checkbox
|
||||
checked={rememberMe}
|
||||
onChange={handleCheckRememberMe}
|
||||
/>
|
||||
}
|
||||
label="Remember device"
|
||||
/>
|
||||
<Button
|
||||
variant="contained"
|
||||
onClick={() => {
|
||||
setQuickConnectCode("");
|
||||
setQuickConnectLoading(-1);
|
||||
}}
|
||||
>
|
||||
Close
|
||||
</Button>
|
||||
</DialogActions>
|
||||
</Dialog>
|
||||
<Grid sx={{ width: "100%" }}>
|
||||
<Paper
|
||||
elevation={5}
|
||||
style={{
|
||||
marginTop: "1em",
|
||||
padding: "1em",
|
||||
borderRadius: "15px",
|
||||
}}
|
||||
>
|
||||
<div
|
||||
className="flex flex-row flex-align-center"
|
||||
style={{ gap: "0.5em", marginBottom: "0.5em" }}
|
||||
>
|
||||
<span
|
||||
className="material-symbols-rounded"
|
||||
style={{
|
||||
color: blue[700],
|
||||
"--fill": 1,
|
||||
}}
|
||||
>
|
||||
info
|
||||
</span>
|
||||
Notice
|
||||
</div>
|
||||
<Typography variant="subtitle2" style={{ opacity: 0.8 }}>
|
||||
{server.isSuccess && server.data.LoginDisclaimer}
|
||||
</Typography>
|
||||
</Paper>
|
||||
</Grid>
|
||||
</Grid>
|
||||
</Container>
|
||||
</>
|
||||
);
|
||||
};
|
||||
@@ -1,33 +1,33 @@
|
||||
import React, { useState } from "react";
|
||||
import { useNavigate } from "react-router-dom";
|
||||
|
||||
import { setDefaultServer, setServer } from "../../../utils/storage/servers";
|
||||
import { setDefaultServer, setServer } from "@/utils/storage/servers";
|
||||
|
||||
import LoadingButton from "@mui/lab/LoadingButton";
|
||||
import Container from "@mui/material/Container";
|
||||
import Grid from "@mui/material/Grid";
|
||||
import LinearProgress from "@mui/material/LinearProgress";
|
||||
import SvgIcon from "@mui/material/SvgIcon";
|
||||
// MUI
|
||||
import TextField from "@mui/material/TextField";
|
||||
import Typography from "@mui/material/Typography";
|
||||
|
||||
import { useSnackbar } from "notistack";
|
||||
|
||||
import { createApi, jellyfin } from "@/utils/store/api";
|
||||
import { yellow } from "@mui/material/colors";
|
||||
import { useMutation } from "@tanstack/react-query";
|
||||
import { createApi, useApi } from "../../../utils/store/api";
|
||||
// SCSS
|
||||
import "./server.scss";
|
||||
import { createFileRoute, useNavigate } from "@tanstack/react-router";
|
||||
|
||||
export const ServerSetup = () => {
|
||||
const [jellyfin] = useApi((state) => [state.jellyfin]);
|
||||
export const Route = createFileRoute("/setup/server/add")({
|
||||
component: ServerSetup,
|
||||
});
|
||||
|
||||
function ServerSetup() {
|
||||
const [serverIp, setServerIp] = useState("");
|
||||
|
||||
const { enqueueSnackbar } = useSnackbar();
|
||||
|
||||
const navigate = useNavigate();
|
||||
const navigate = useNavigate({ from: "/setup/server/add" });
|
||||
|
||||
const checkServer = useMutation({
|
||||
mutationFn: async () => {
|
||||
@@ -40,14 +40,14 @@ export const ServerSetup = () => {
|
||||
if (bestServer) {
|
||||
createApi(bestServer.address, undefined);
|
||||
|
||||
setDefaultServer(bestServer.systemInfo.Id);
|
||||
setServer(bestServer.systemInfo.Id, bestServer);
|
||||
setDefaultServer(bestServer.systemInfo?.Id);
|
||||
setServer(bestServer.systemInfo?.Id, bestServer);
|
||||
|
||||
enqueueSnackbar("Client added successfully", {
|
||||
variant: "success",
|
||||
});
|
||||
|
||||
navigate("/login/index");
|
||||
navigate({ to: "/login/index" });
|
||||
}
|
||||
},
|
||||
onError: (err) => {
|
||||
@@ -149,4 +149,4 @@ export const ServerSetup = () => {
|
||||
</Container>
|
||||
</>
|
||||
);
|
||||
};
|
||||
}
|
||||
@@ -1,29 +1,31 @@
|
||||
import React, { useLayoutEffect, useState } from "react";
|
||||
|
||||
import { relaunch } from "@tauri-apps/api/process";
|
||||
|
||||
import Chip from "@mui/material/Chip";
|
||||
import IconButton from "@mui/material/IconButton";
|
||||
import Paper from "@mui/material/Paper";
|
||||
import Typography from "@mui/material/Typography";
|
||||
import { red } from "@mui/material/colors";
|
||||
|
||||
import { useMutation, useQuery, useQueryClient } from "@tanstack/react-query";
|
||||
import { useSnackbar } from "notistack";
|
||||
import { useNavigate } from "react-router-dom";
|
||||
import { AppBarBackOnly } from "../../../components/appBar/backOnly";
|
||||
import { AppBarBackOnly } from "@/components/appBar/backOnly";
|
||||
import {
|
||||
delServer,
|
||||
getAllServers,
|
||||
getDefaultServer,
|
||||
setDefaultServer,
|
||||
} from "../../../utils/storage/servers";
|
||||
import { delUser } from "../../../utils/storage/user";
|
||||
import { createApi, useApi } from "../../../utils/store/api";
|
||||
import { setBackdrop } from "../../../utils/store/backdrop";
|
||||
} from "@/utils/storage/servers";
|
||||
import { delUser } from "@/utils/storage/user";
|
||||
import { createApi } from "@/utils/store/api";
|
||||
import { setBackdrop } from "@/utils/store/backdrop";
|
||||
import { useMutation, useQuery, useQueryClient } from "@tanstack/react-query";
|
||||
import { createFileRoute, useNavigate } from "@tanstack/react-router";
|
||||
import { useSnackbar } from "notistack";
|
||||
import "./serverList.scss";
|
||||
|
||||
const ServerList = () => {
|
||||
export const Route = createFileRoute("/setup/server/list")({
|
||||
component: ServerList,
|
||||
});
|
||||
|
||||
function ServerList() {
|
||||
const navigate = useNavigate();
|
||||
const [serverState, setServerState] = useState(null);
|
||||
const { enqueueSnackbar } = useSnackbar();
|
||||
@@ -46,11 +48,11 @@ const ServerList = () => {
|
||||
await setDefaultServer(serverState.id);
|
||||
queryClient.clear();
|
||||
await defaultServer.refetch();
|
||||
createApi(serverState.address);
|
||||
createApi(serverState.address, undefined);
|
||||
queryClient.removeQueries();
|
||||
},
|
||||
onSuccess: async () => {
|
||||
navigate("/login/index");
|
||||
navigate({ to: "/login/index" });
|
||||
},
|
||||
onError: (error) => {
|
||||
console.error(error);
|
||||
@@ -69,12 +71,12 @@ const ServerList = () => {
|
||||
|
||||
if (servers.length > 0) {
|
||||
setDefaultServer(servers[0].id);
|
||||
createApi(servers[0].address);
|
||||
createApi(servers[0].address, undefined);
|
||||
} else {
|
||||
useApi.setState(useApi.getInitialState());
|
||||
// TODO: reset api in context here
|
||||
}
|
||||
queryClient.removeQueries();
|
||||
navigate("/");
|
||||
navigate({ to: "/" });
|
||||
}
|
||||
enqueueSnackbar("Server deleted successfully!", { variant: "success" });
|
||||
|
||||
@@ -105,7 +107,7 @@ const ServerList = () => {
|
||||
style={{
|
||||
fontSize: "1.64em",
|
||||
}}
|
||||
onClick={() => navigate("/setup/server")}
|
||||
onClick={() => navigate({ to: "/setup/server" })}
|
||||
>
|
||||
<div className="material-symbols-rounded">add</div>
|
||||
</IconButton>
|
||||
@@ -198,5 +200,5 @@ const ServerList = () => {
|
||||
</Paper>
|
||||
</div>
|
||||
);
|
||||
};
|
||||
}
|
||||
export default ServerList;
|
||||
File renamed without changes.
File renamed without changes.
Reference in new issue
Block a user