Move to Tauri and rust
This commit is contained in:
77 files changed
+7861
-975
No files matched your search
+41
@@ -0,0 +1,41 @@
|
||||
#root {
|
||||
max-width: 1280px;
|
||||
margin: 0 auto;
|
||||
padding: 2rem;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.logo {
|
||||
height: 6em;
|
||||
padding: 1.5em;
|
||||
will-change: filter;
|
||||
}
|
||||
.logo:hover {
|
||||
filter: drop-shadow(0 0 2em #646cffaa);
|
||||
}
|
||||
.logo.react:hover {
|
||||
filter: drop-shadow(0 0 2em #61dafbaa);
|
||||
}
|
||||
|
||||
@keyframes logo-spin {
|
||||
from {
|
||||
transform: rotate(0deg);
|
||||
}
|
||||
to {
|
||||
transform: rotate(360deg);
|
||||
}
|
||||
}
|
||||
|
||||
@media (prefers-reduced-motion: no-preference) {
|
||||
a:nth-of-type(2) .logo {
|
||||
animation: logo-spin infinite 20s linear;
|
||||
}
|
||||
}
|
||||
|
||||
.card {
|
||||
padding: 2em;
|
||||
}
|
||||
|
||||
.read-the-docs {
|
||||
color: #888;
|
||||
}
|
||||
+226
@@ -0,0 +1,226 @@
|
||||
/** @format */
|
||||
|
||||
import { useState, useEffect, useContext } from "react";
|
||||
import { ThemeProvider } from "@mui/material/styles";
|
||||
import { SnackbarProvider } from "notistack";
|
||||
import { useCookies, Cookies } from "react-cookie";
|
||||
import {
|
||||
Routes,
|
||||
Route,
|
||||
Navigate,
|
||||
useNavigate,
|
||||
useLocation,
|
||||
Outlet,
|
||||
} from "react-router-dom";
|
||||
import { AnimatePresence, motion } from "framer-motion";
|
||||
|
||||
import { EventEmitter as event } from "./eventEmitter.js";
|
||||
|
||||
import { getUserApi } from "@jellyfin/sdk/lib/utils/api/user-api";
|
||||
|
||||
// Theming
|
||||
import { theme } from "./theme";
|
||||
import "./styles/global.scss";
|
||||
|
||||
// Routes
|
||||
import { ServerSetup, ServerList } from "./routes/setup/server/root";
|
||||
import { Home } from "./routes/home/root";
|
||||
import {
|
||||
UserLogin,
|
||||
LoginWithImage,
|
||||
UserLoginManual,
|
||||
} from "./routes/login/root";
|
||||
|
||||
// Fonts
|
||||
import "@fontsource/open-sans";
|
||||
|
||||
// Jellyfin SDK TypeScript
|
||||
import { Jellyfin } from "@jellyfin/sdk";
|
||||
import { version as appVer } from "../package.json";
|
||||
import { v4 as uuidv4 } from "uuid";
|
||||
|
||||
const jellyfin = new Jellyfin({
|
||||
clientInfo: {
|
||||
name: "JellyPlayer",
|
||||
version: appVer,
|
||||
},
|
||||
deviceInfo: {
|
||||
name: "JellyPlayer",
|
||||
id: uuidv4(),
|
||||
},
|
||||
});
|
||||
|
||||
event.on("create-jellyfin-api", (serverAddress) => {
|
||||
window.api = jellyfin.createApi(
|
||||
serverAddress,
|
||||
sessionStorage.getItem("accessToken"),
|
||||
);
|
||||
// window.api = jellyfin.createApi(serverAddress);
|
||||
});
|
||||
event.on("set-api-accessToken", (serverAddress) => {
|
||||
window.api = jellyfin.createApi(
|
||||
serverAddress,
|
||||
sessionStorage.getItem("accessToken"),
|
||||
);
|
||||
});
|
||||
|
||||
const anim = {
|
||||
initial: {
|
||||
opacity: 0,
|
||||
x: -50,
|
||||
},
|
||||
animate: {
|
||||
opacity: 1,
|
||||
x: 0,
|
||||
},
|
||||
exit: {
|
||||
opacity: 0,
|
||||
x: 50,
|
||||
},
|
||||
};
|
||||
|
||||
const AnimationWrapper = () => {
|
||||
return (
|
||||
<motion.div
|
||||
className="root-page"
|
||||
variants={anim}
|
||||
initial="initial"
|
||||
animate="animate"
|
||||
exit="exit"
|
||||
transition={{
|
||||
duration: 0.3,
|
||||
ease: "easeInOut",
|
||||
}}
|
||||
>
|
||||
<Outlet />
|
||||
</motion.div>
|
||||
);
|
||||
};
|
||||
|
||||
function App() {
|
||||
const [userCookies] = useCookies(["user"]);
|
||||
const navigate = useNavigate();
|
||||
const cookies = new Cookies();
|
||||
|
||||
const serverAvailable = () => {
|
||||
try {
|
||||
const currentServer = cookies.get("currentServer");
|
||||
const serverList = cookies.get("servers");
|
||||
let currentServerIp = "";
|
||||
serverList.map((item, index) => {
|
||||
currentServerIp = item[currentServer];
|
||||
});
|
||||
|
||||
if (currentServer == undefined) {
|
||||
return false;
|
||||
} else {
|
||||
if (!window.api) {
|
||||
event.emit(
|
||||
"create-jellyfin-api",
|
||||
currentServerIp.serverAddress,
|
||||
);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
} catch (error) {
|
||||
return false;
|
||||
}
|
||||
};
|
||||
|
||||
const userSaved = () => {
|
||||
try {
|
||||
userCookies.user[0];
|
||||
return true;
|
||||
} catch (error) {
|
||||
return false;
|
||||
}
|
||||
};
|
||||
|
||||
const userAvailable = async () => {
|
||||
const users = await getUserApi(window.api).getPublicUsers();
|
||||
try {
|
||||
if (users.data.length >= 1) {
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
} catch (error) {
|
||||
return false;
|
||||
}
|
||||
};
|
||||
|
||||
const HandleLoginRoutes = () => {
|
||||
if (userSaved()) {
|
||||
navigate("/home");
|
||||
} else {
|
||||
userAvailable().then((res) => {
|
||||
if (res) {
|
||||
navigate("/login/users");
|
||||
} else if (!res) {
|
||||
navigate("/login/manual");
|
||||
}
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
const location = useLocation();
|
||||
|
||||
return (
|
||||
<SnackbarProvider maxSnack={5}>
|
||||
<ThemeProvider theme={theme}>
|
||||
<AnimatePresence>
|
||||
<Routes key={location.pathname} location={location}>
|
||||
<Route element={<AnimationWrapper />}>
|
||||
{/* Main Routes */}
|
||||
<Route path="/home" element={<Home />} />
|
||||
<Route
|
||||
path="/setup/server"
|
||||
element={<ServerSetup />}
|
||||
/>
|
||||
<Route
|
||||
path="/servers/list"
|
||||
element={<ServerList />}
|
||||
/>
|
||||
<Route
|
||||
exact
|
||||
path="/login/withImg/:userName/:userId/"
|
||||
element={<LoginWithImage />}
|
||||
/>
|
||||
<Route
|
||||
exact
|
||||
path="/login/users"
|
||||
element={<UserLogin />}
|
||||
/>
|
||||
<Route
|
||||
path="/login/manual"
|
||||
element={<UserLoginManual />}
|
||||
/>
|
||||
|
||||
{/* Logical Routes */}
|
||||
<Route
|
||||
exact
|
||||
path="/login"
|
||||
element={
|
||||
<HandleLoginRoutes></HandleLoginRoutes>
|
||||
}
|
||||
/>
|
||||
|
||||
<Route
|
||||
path="/"
|
||||
element={
|
||||
serverAvailable() ? (
|
||||
<Navigate to="/login" />
|
||||
) : (
|
||||
<Navigate to="/setup/server" />
|
||||
)
|
||||
}
|
||||
/>
|
||||
</Route>
|
||||
</Routes>
|
||||
</AnimatePresence>
|
||||
</ThemeProvider>
|
||||
</SnackbarProvider>
|
||||
);
|
||||
}
|
||||
|
||||
export default App;
|
||||
@@ -0,0 +1 @@
|
||||
/** @format */
|
||||
@@ -0,0 +1,28 @@
|
||||
<svg width="5000" height="455" viewBox="0 0 5000 455" fill="none" xmlns="http://www.w3.org/2000/svg">
|
||||
<path d="M174.178 454.868C144.522 454.868 116.954 448.185 91.4748 434.818C65.9955 421.035 45.1108 402.238 28.8208 378.43C12.5308 354.621 2.92385 328.307 0 299.486H23.182C26.1058 324.13 34.6685 346.685 48.8701 367.152C63.0716 387.201 81.0324 403.074 102.752 414.769C124.89 426.047 148.699 431.686 174.178 431.686C202.163 431.686 227.852 424.794 251.242 411.01C274.633 397.226 293.22 378.221 307.004 353.995C320.788 329.769 327.68 302.619 327.68 272.545V32.58H132.2V9.39808H350.236V272.545C350.236 306.796 342.299 337.914 326.427 365.899C310.972 393.467 289.67 415.187 262.52 431.059C235.788 446.931 206.34 454.868 174.178 454.868Z" fill="white"/>
|
||||
<path d="M495.113 9.39808H802.117V32.58H518.295V209.264H765.152V232.446H518.295V422.288H802.117V445.47H495.113V9.39808Z" fill="white"/>
|
||||
<path d="M974.562 445.47V9.39808H997.744V422.288H1301.62V445.47H974.562Z" fill="white"/>
|
||||
<path d="M1438.35 445.47V9.39808H1461.53V422.288H1765.4V445.47H1438.35Z" fill="white"/>
|
||||
<path d="M1882.71 9.39808L2037.47 242.471L2190.97 9.39808H2218.54L2048.74 266.906V445.47H2025.56V266.906L1855.14 9.39808H1882.71Z" fill="white"/>
|
||||
<path d="M2379.08 445.47H2355.9V9.39808H2531.33C2560.57 9.39808 2587.51 15.6635 2612.15 28.1943C2637.21 40.7251 2657.05 58.477 2671.67 81.4501C2686.29 104.423 2693.6 130.947 2693.6 161.021C2693.6 189.841 2686.08 216.365 2671.05 240.591C2656.43 264.817 2636.38 283.405 2610.9 296.353C2588.76 307.631 2562.24 313.27 2531.33 313.27H2379.08V445.47ZM2379.08 290.088H2531.33C2558.06 290.088 2579.99 285.911 2597.11 277.557C2619.25 267.115 2637 251.451 2650.37 230.566C2663.74 209.682 2670.42 186.5 2670.42 161.021C2670.42 135.959 2663.74 112.986 2650.37 92.1013C2637 71.2167 2619.04 55.5532 2596.49 45.1108C2579.36 36.757 2557.64 32.58 2531.33 32.58H2379.08V290.088Z" fill="white"/>
|
||||
<path d="M2829.71 445.47V9.39808H2852.89V422.288H3156.76V445.47H2829.71Z" fill="white"/>
|
||||
<path d="M3633.7 445.47H3222.69L3428.2 0L3633.7 445.47Z" fill="url(#paint0_linear_303_3)"/>
|
||||
<path d="M3737.86 9.39808L3892.61 242.471L4046.11 9.39808H4073.68L3903.89 266.906V445.47H3880.71V266.906L3710.29 9.39808H3737.86Z" fill="white"/>
|
||||
<path d="M4205.4 9.39808H4512.41V32.58H4228.58V209.264H4475.44V232.446H4228.58V422.288H4512.41V445.47H4205.4V9.39808Z" fill="white"/>
|
||||
<path d="M4914.16 23.8085C4939.23 35.5039 4958.86 52.8382 4973.06 75.8113C4987.68 98.7844 4994.99 124.264 4994.99 152.249C4994.99 184.829 4984.96 214.068 4964.91 239.965C4945.28 265.444 4914.58 285.776 4883.67 294.13L4664.8 9.39808H4830.83C4849.21 9.39808 4864.88 10.6512 4877.83 13.1573C4891.19 15.2458 4903.3 18.7962 4914.16 23.8085Z" fill="url(#paint1_linear_303_3)"/>
|
||||
<path d="M5000 445.47L4883.67 294.13H4664.8V445.47H5000Z" fill="url(#paint2_linear_303_3)"/>
|
||||
<defs>
|
||||
<linearGradient id="paint0_linear_303_3" x1="3532.59" y1="229.314" x2="3227.04" y2="442.278" gradientUnits="userSpaceOnUse">
|
||||
<stop stop-color="#FB2576"/>
|
||||
<stop offset="1" stop-color="#150050"/>
|
||||
</linearGradient>
|
||||
<linearGradient id="paint1_linear_303_3" x1="4953.89" y1="53.3888" x2="4666.85" y2="442.278" gradientUnits="userSpaceOnUse">
|
||||
<stop stop-color="#FB2576"/>
|
||||
<stop offset="1" stop-color="#150050"/>
|
||||
</linearGradient>
|
||||
<linearGradient id="paint2_linear_303_3" x1="4953.89" y1="53.3888" x2="4666.85" y2="442.278" gradientUnits="userSpaceOnUse">
|
||||
<stop stop-color="#FB2576"/>
|
||||
<stop offset="1" stop-color="#150050"/>
|
||||
</linearGradient>
|
||||
</defs>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 3.4 KiB |
@@ -0,0 +1 @@
|
||||
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" aria-hidden="true" role="img" class="iconify iconify--logos" width="35.93" height="32" preserveAspectRatio="xMidYMid meet" viewBox="0 0 256 228"><path fill="#00D8FF" d="M210.483 73.824a171.49 171.49 0 0 0-8.24-2.597c.465-1.9.893-3.777 1.273-5.621c6.238-30.281 2.16-54.676-11.769-62.708c-13.355-7.7-35.196.329-57.254 19.526a171.23 171.23 0 0 0-6.375 5.848a155.866 155.866 0 0 0-4.241-3.917C100.759 3.829 77.587-4.822 63.673 3.233C50.33 10.957 46.379 33.89 51.995 62.588a170.974 170.974 0 0 0 1.892 8.48c-3.28.932-6.445 1.924-9.474 2.98C17.309 83.498 0 98.307 0 113.668c0 15.865 18.582 31.778 46.812 41.427a145.52 145.52 0 0 0 6.921 2.165a167.467 167.467 0 0 0-2.01 9.138c-5.354 28.2-1.173 50.591 12.134 58.266c13.744 7.926 36.812-.22 59.273-19.855a145.567 145.567 0 0 0 5.342-4.923a168.064 168.064 0 0 0 6.92 6.314c21.758 18.722 43.246 26.282 56.54 18.586c13.731-7.949 18.194-32.003 12.4-61.268a145.016 145.016 0 0 0-1.535-6.842c1.62-.48 3.21-.974 4.76-1.488c29.348-9.723 48.443-25.443 48.443-41.52c0-15.417-17.868-30.326-45.517-39.844Zm-6.365 70.984c-1.4.463-2.836.91-4.3 1.345c-3.24-10.257-7.612-21.163-12.963-32.432c5.106-11 9.31-21.767 12.459-31.957c2.619.758 5.16 1.557 7.61 2.4c23.69 8.156 38.14 20.213 38.14 29.504c0 9.896-15.606 22.743-40.946 31.14Zm-10.514 20.834c2.562 12.94 2.927 24.64 1.23 33.787c-1.524 8.219-4.59 13.698-8.382 15.893c-8.067 4.67-25.32-1.4-43.927-17.412a156.726 156.726 0 0 1-6.437-5.87c7.214-7.889 14.423-17.06 21.459-27.246c12.376-1.098 24.068-2.894 34.671-5.345a134.17 134.17 0 0 1 1.386 6.193ZM87.276 214.515c-7.882 2.783-14.16 2.863-17.955.675c-8.075-4.657-11.432-22.636-6.853-46.752a156.923 156.923 0 0 1 1.869-8.499c10.486 2.32 22.093 3.988 34.498 4.994c7.084 9.967 14.501 19.128 21.976 27.15a134.668 134.668 0 0 1-4.877 4.492c-9.933 8.682-19.886 14.842-28.658 17.94ZM50.35 144.747c-12.483-4.267-22.792-9.812-29.858-15.863c-6.35-5.437-9.555-10.836-9.555-15.216c0-9.322 13.897-21.212 37.076-29.293c2.813-.98 5.757-1.905 8.812-2.773c3.204 10.42 7.406 21.315 12.477 32.332c-5.137 11.18-9.399 22.249-12.634 32.792a134.718 134.718 0 0 1-6.318-1.979Zm12.378-84.26c-4.811-24.587-1.616-43.134 6.425-47.789c8.564-4.958 27.502 2.111 47.463 19.835a144.318 144.318 0 0 1 3.841 3.545c-7.438 7.987-14.787 17.08-21.808 26.988c-12.04 1.116-23.565 2.908-34.161 5.309a160.342 160.342 0 0 1-1.76-7.887Zm110.427 27.268a347.8 347.8 0 0 0-7.785-12.803c8.168 1.033 15.994 2.404 23.343 4.08c-2.206 7.072-4.956 14.465-8.193 22.045a381.151 381.151 0 0 0-7.365-13.322Zm-45.032-43.861c5.044 5.465 10.096 11.566 15.065 18.186a322.04 322.04 0 0 0-30.257-.006c4.974-6.559 10.069-12.652 15.192-18.18ZM82.802 87.83a323.167 323.167 0 0 0-7.227 13.238c-3.184-7.553-5.909-14.98-8.134-22.152c7.304-1.634 15.093-2.97 23.209-3.984a321.524 321.524 0 0 0-7.848 12.897Zm8.081 65.352c-8.385-.936-16.291-2.203-23.593-3.793c2.26-7.3 5.045-14.885 8.298-22.6a321.187 321.187 0 0 0 7.257 13.246c2.594 4.48 5.28 8.868 8.038 13.147Zm37.542 31.03c-5.184-5.592-10.354-11.779-15.403-18.433c4.902.192 9.899.29 14.978.29c5.218 0 10.376-.117 15.453-.343c-4.985 6.774-10.018 12.97-15.028 18.486Zm52.198-57.817c3.422 7.8 6.306 15.345 8.596 22.52c-7.422 1.694-15.436 3.058-23.88 4.071a382.417 382.417 0 0 0 7.859-13.026a347.403 347.403 0 0 0 7.425-13.565Zm-16.898 8.101a358.557 358.557 0 0 1-12.281 19.815a329.4 329.4 0 0 1-23.444.823c-7.967 0-15.716-.248-23.178-.732a310.202 310.202 0 0 1-12.513-19.846h.001a307.41 307.41 0 0 1-10.923-20.627a310.278 310.278 0 0 1 10.89-20.637l-.001.001a307.318 307.318 0 0 1 12.413-19.761c7.613-.576 15.42-.876 23.31-.876H128c7.926 0 15.743.303 23.354.883a329.357 329.357 0 0 1 12.335 19.695a358.489 358.489 0 0 1 11.036 20.54a329.472 329.472 0 0 1-11 20.722Zm22.56-122.124c8.572 4.944 11.906 24.881 6.52 51.026c-.344 1.668-.73 3.367-1.15 5.09c-10.622-2.452-22.155-4.275-34.23-5.408c-7.034-10.017-14.323-19.124-21.64-27.008a160.789 160.789 0 0 1 5.888-5.4c18.9-16.447 36.564-22.941 44.612-18.3ZM128 90.808c12.625 0 22.86 10.235 22.86 22.86s-10.235 22.86-22.86 22.86s-22.86-10.235-22.86-22.86s10.235-22.86 22.86-22.86Z"></path></svg>
|
||||
|
After Width: | Height: | Size: 4.0 KiB |
@@ -0,0 +1,32 @@
|
||||
/** @format */
|
||||
|
||||
import AppBar from "@mui/material/AppBar";
|
||||
import Toolbar from "@mui/material/Toolbar";
|
||||
import IconButton from "@mui/material/IconButton";
|
||||
import ArrowLeft from "mdi-material-ui/ArrowLeft";
|
||||
import { useNavigate } from "react-router-dom";
|
||||
|
||||
export const AppBarBackOnly = () => {
|
||||
const navigate = useNavigate();
|
||||
|
||||
const handleBack = () => {
|
||||
navigate(-1);
|
||||
};
|
||||
|
||||
return (
|
||||
<AppBar elevation={0} color="transparent" position="fixed">
|
||||
<Toolbar>
|
||||
<IconButton
|
||||
size="large"
|
||||
edge="start"
|
||||
color="white"
|
||||
aria-label="back"
|
||||
onClick={handleBack}
|
||||
sx={{ mr: 2 }}
|
||||
>
|
||||
<ArrowLeft />
|
||||
</IconButton>
|
||||
</Toolbar>
|
||||
</AppBar>
|
||||
);
|
||||
};
|
||||
@@ -0,0 +1,77 @@
|
||||
/** @format */
|
||||
import PropTypes from "prop-types";
|
||||
|
||||
import Typography from "@mui/material/Typography";
|
||||
import ButtonBase from "@mui/material/ButtonBase";
|
||||
|
||||
import Account from "mdi-material-ui/Account";
|
||||
|
||||
import "./avatar.module.scss";
|
||||
|
||||
export const AvatarCard = ({ userName, userId, userImageAvailable }) => {
|
||||
return (
|
||||
<ButtonBase className="card square">
|
||||
<div className="card-image-container">
|
||||
{userImageAvailable ? (
|
||||
<div
|
||||
className="card-image"
|
||||
style={{
|
||||
backgroundImage:
|
||||
"url('" +
|
||||
window.api.basePath +
|
||||
"/Users/" +
|
||||
userId +
|
||||
"/Images/Primary')",
|
||||
}}
|
||||
></div>
|
||||
) : (
|
||||
<div className="card-image empty"></div>
|
||||
)}
|
||||
<div className="card-image-icon-container">
|
||||
<Account className="card-image-icon" />
|
||||
</div>
|
||||
</div>
|
||||
<div className="card-text-container">
|
||||
<Typography
|
||||
variant="button"
|
||||
color="textPrimary"
|
||||
className="card-text"
|
||||
>
|
||||
{userName}
|
||||
</Typography>
|
||||
</div>
|
||||
</ButtonBase>
|
||||
);
|
||||
};
|
||||
|
||||
export const AvatarImage = ({ userId }) => {
|
||||
return (
|
||||
<div className="avatar-image-container">
|
||||
<div
|
||||
className="avatar-image"
|
||||
style={{
|
||||
backgroundImage:
|
||||
"url('" +
|
||||
window.api.basePath +
|
||||
"/Users/" +
|
||||
userId +
|
||||
"/Images/Primary')",
|
||||
}}
|
||||
></div>
|
||||
|
||||
<div className="avatar-image-icon-container">
|
||||
<Account className="avatar-image-icon" />
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
};
|
||||
|
||||
AvatarCard.propType = {
|
||||
userName: PropTypes.string.isRequired,
|
||||
userId: PropTypes.string.isRequired,
|
||||
userImageAvailable: PropTypes.bool.isRequired,
|
||||
};
|
||||
|
||||
AvatarImage.propType = {
|
||||
userId: PropTypes.string.isRequired,
|
||||
};
|
||||
@@ -0,0 +1,50 @@
|
||||
/** @format */
|
||||
|
||||
.userCard {
|
||||
text-decoration: none !important;
|
||||
}
|
||||
|
||||
.card.square {
|
||||
width: fit-content;
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
flex-direction: column;
|
||||
gap: 0.5em;
|
||||
margin-bottom: 0.5em;
|
||||
.card-image {
|
||||
&-container {
|
||||
font-size: 5em;
|
||||
}
|
||||
&-icon {
|
||||
font-size: 1.5em !important;
|
||||
&-container {
|
||||
position: static;
|
||||
width: 1.5em !important;
|
||||
height: 1.5em !important;
|
||||
aspect-ratio: 1;
|
||||
border-radius: $border-radius-default;
|
||||
color: $clr-accent-default;
|
||||
background: $clr-accent-dark;
|
||||
}
|
||||
}
|
||||
}
|
||||
.card-text {
|
||||
margin: 0 !important;
|
||||
text-decoration: none !important;
|
||||
}
|
||||
}
|
||||
|
||||
.avatar-image {
|
||||
&-container {
|
||||
width: fit-content;
|
||||
aspect-ratio: 1;
|
||||
}
|
||||
&-icon {
|
||||
border-radius: 100%;
|
||||
padding: 0.2em;
|
||||
background: $clr-accent-dark;
|
||||
color: $clr-accent-default;
|
||||
font-size: 6em !important;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,110 @@
|
||||
/** @format */
|
||||
import React from "react";
|
||||
import PropTypes from "prop-types";
|
||||
|
||||
import Typography from "@mui/material/Typography";
|
||||
|
||||
import {
|
||||
MediaCollectionTypeIconCollectionCard,
|
||||
MediaTypeIconCollectionCard,
|
||||
} from "../utils/iconsCollection";
|
||||
|
||||
import "./card.module.scss";
|
||||
|
||||
export const CardLandscape = ({ itemName, itemId, imageTags, iconType }) => {
|
||||
const imageAvailable = () => {
|
||||
console.log(imageTags);
|
||||
if (imageTags == undefined) {
|
||||
console.log("hee");
|
||||
return false;
|
||||
} else {
|
||||
return true;
|
||||
}
|
||||
};
|
||||
return (
|
||||
<div className="card landscape">
|
||||
<div className="card-image-container">
|
||||
{imageAvailable ? (
|
||||
<div
|
||||
className="card-image"
|
||||
style={{
|
||||
backgroundImage:
|
||||
"url('" +
|
||||
window.api.basePath +
|
||||
"/Items/" +
|
||||
itemId +
|
||||
"/Images/Primary')",
|
||||
}}
|
||||
></div>
|
||||
) : (
|
||||
<div className="card-image empty"></div>
|
||||
)}
|
||||
<div className="card-image-icon-container">
|
||||
{MediaCollectionTypeIconCollectionCard[iconType]}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div className="card-text-container">
|
||||
<Typography variant="button" color="white">
|
||||
{itemName}
|
||||
</Typography>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
};
|
||||
|
||||
export const CardPotrait = ({ itemName, itemId, imageTags, iconType }) => {
|
||||
const imageAvailable = () => {
|
||||
console.log(imageTags);
|
||||
if (imageTags == undefined) {
|
||||
console.log("hee");
|
||||
return false;
|
||||
} else {
|
||||
return true;
|
||||
}
|
||||
};
|
||||
return (
|
||||
<div className="card portrait">
|
||||
<div className="card-image-container">
|
||||
{imageAvailable ? (
|
||||
<div
|
||||
className="card-image"
|
||||
style={{
|
||||
backgroundImage:
|
||||
"url('" +
|
||||
window.api.basePath +
|
||||
"/Items/" +
|
||||
itemId +
|
||||
"/Images/Primary?quality=95&fillHeight=350&fillWidth=243')",
|
||||
}}
|
||||
></div>
|
||||
) : (
|
||||
<div className="card-image empty"></div>
|
||||
)}
|
||||
<div className="card-image-icon-container">
|
||||
{MediaTypeIconCollectionCard[iconType]}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div className="card-text-container">
|
||||
<Typography variant="button" color="white">
|
||||
{itemName}
|
||||
</Typography>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
};
|
||||
|
||||
CardLandscape.propTypes = {
|
||||
itemName: PropTypes.string.isRequired,
|
||||
itemId: PropTypes.string.isRequired,
|
||||
imageTags: PropTypes.object,
|
||||
iconType: PropTypes.string.isRequired,
|
||||
};
|
||||
|
||||
CardPotrait.propTypes = {
|
||||
itemName: PropTypes.string.isRequired,
|
||||
itemId: PropTypes.string.isRequired,
|
||||
imageTags: PropTypes.object,
|
||||
iconType: PropTypes.string.isRequired,
|
||||
};
|
||||
@@ -0,0 +1,52 @@
|
||||
/** @format */
|
||||
|
||||
.card {
|
||||
margin-right: 1em;
|
||||
|
||||
&.landscape {
|
||||
--image-aspect-ratio: 1.77;
|
||||
}
|
||||
|
||||
&.portrait {
|
||||
--image-aspect-ratio: 0.65;
|
||||
}
|
||||
|
||||
&-image {
|
||||
position: relative;
|
||||
z-index: 1;
|
||||
border-radius: 10px;
|
||||
aspect-ratio: var(--image-aspect-ratio);
|
||||
background-size: cover;
|
||||
background-position: center;
|
||||
&-container {
|
||||
position: relative;
|
||||
}
|
||||
&-icon {
|
||||
font-size: 4.5em !important;
|
||||
|
||||
&-container {
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
position: absolute;
|
||||
top: 0;
|
||||
left: 0;
|
||||
right: 0;
|
||||
bottom: 0;
|
||||
width: 100% !important;
|
||||
height: 100% !important;
|
||||
border-radius: $border-radius-default;
|
||||
color: $clr-accent-default;
|
||||
background: $clr-accent-dark;
|
||||
z-index: 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
&-text-container {
|
||||
margin-top: 0.5em;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,83 @@
|
||||
/** @format */
|
||||
|
||||
import { useRef, useEffect } from "react";
|
||||
import PropTypes from "prop-types";
|
||||
|
||||
import Carousel from "react-multi-carousel";
|
||||
import "react-multi-carousel/lib/styles.css";
|
||||
|
||||
import ChevronLeft from "mdi-material-ui/ChevronLeft";
|
||||
import ChevronRight from "mdi-material-ui/ChevronRight";
|
||||
|
||||
import { styled } from "@mui/material/styles";
|
||||
import Button from "@mui/material/Button";
|
||||
import ButtonGroup from "@mui/material/ButtonGroup";
|
||||
|
||||
import "./cardScroller.module.scss";
|
||||
|
||||
const CarouselButton = styled(Button)(() => ({
|
||||
color: "white",
|
||||
height: "100%",
|
||||
}));
|
||||
|
||||
const SliderButtonRight = ({ onClick }) => {
|
||||
return (
|
||||
<CarouselButton
|
||||
onClick={() => onClick()}
|
||||
className="card-scroller-button right"
|
||||
variant="text"
|
||||
>
|
||||
<ChevronRight />
|
||||
</CarouselButton>
|
||||
);
|
||||
};
|
||||
|
||||
const SliderButtonLeft = ({ onClick }) => {
|
||||
return (
|
||||
<CarouselButton
|
||||
onClick={() => onClick()}
|
||||
className="card-scroller-button left"
|
||||
variant="text"
|
||||
>
|
||||
<ChevronLeft />
|
||||
</CarouselButton>
|
||||
);
|
||||
};
|
||||
|
||||
export const CardScroller = ({ children, displayCards }) => {
|
||||
const responsive = {
|
||||
desktop: {
|
||||
breakpoint: { max: 3000, min: 1024 },
|
||||
items: displayCards,
|
||||
slidesToSlide: displayCards, // optional, default to 1.
|
||||
},
|
||||
tablet: {
|
||||
breakpoint: { max: 1024, min: 464 },
|
||||
items: displayCards - 1,
|
||||
slidesToSlide: displayCards - 1, // optional, default to 1.
|
||||
},
|
||||
mobile: {
|
||||
breakpoint: { max: 464, min: 0 },
|
||||
items: displayCards - 2,
|
||||
slidesToSlide: displayCards - 2, // optional, default to 1.
|
||||
},
|
||||
};
|
||||
|
||||
return (
|
||||
<Carousel
|
||||
swipeable={false}
|
||||
draggable={false}
|
||||
responsive={responsive}
|
||||
arrows={true}
|
||||
customRightArrow={<SliderButtonRight />}
|
||||
customLeftArrow={<SliderButtonLeft />}
|
||||
className="card-scroller"
|
||||
>
|
||||
{children}
|
||||
</Carousel>
|
||||
);
|
||||
};
|
||||
|
||||
CardScroller.propTypes = {
|
||||
displayCards: PropTypes.number.isRequired,
|
||||
};
|
||||
@@ -0,0 +1,29 @@
|
||||
/** @format */
|
||||
|
||||
.card-scroller {
|
||||
// height: 20em;
|
||||
&-slide {
|
||||
overflow: visible;
|
||||
display: flex;
|
||||
}
|
||||
&-button {
|
||||
color: white;
|
||||
position: absolute !important;
|
||||
top: 49%;
|
||||
transform: translateY(-50%);
|
||||
background-color: $clr-background-dark !important;
|
||||
border-radius: $border-radius-intensity-1 !important;
|
||||
opacity: 0;
|
||||
transition: opacity $transition-time-default !important;
|
||||
&:hover,
|
||||
&:focus {
|
||||
opacity: 1;
|
||||
}
|
||||
&.right {
|
||||
right: 0%;
|
||||
}
|
||||
&.left {
|
||||
left: 0%;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,61 @@
|
||||
/** @format */
|
||||
|
||||
import MovieOutline from "mdi-material-ui/MovieOutline";
|
||||
import MusicBoxMultipleOutline from "mdi-material-ui/MusicBoxMultipleOutline";
|
||||
import PlaylistMusicOutline from "mdi-material-ui/PlaylistMusicOutline";
|
||||
import Television from "mdi-material-ui/Television";
|
||||
import FolderOutline from "mdi-material-ui/FolderOutline";
|
||||
import FolderMusicOutline from "mdi-material-ui/FolderMusicOutline";
|
||||
import Youtube from "mdi-material-ui/Youtube";
|
||||
import MultiMedia from "mdi-material-ui/Multimedia";
|
||||
import BookMultiple from "mdi-material-ui/BookMultiple";
|
||||
import ImageMultiple from "mdi-material-ui/ImageMultiple";
|
||||
import TelevisionClassic from "mdi-material-ui/TelevisionClassic";
|
||||
import Filmstrip from "mdi-material-ui/Filmstrip";
|
||||
import Microphone from "mdi-material-ui/Microphone";
|
||||
import Image from "mdi-material-ui/Image";
|
||||
import Book from "mdi-material-ui/Book";
|
||||
|
||||
export const MediaCollectionTypeIconCollection = {
|
||||
universal: <MultiMedia />,
|
||||
movies: <MovieOutline />,
|
||||
music: <MusicBoxMultipleOutline />,
|
||||
playlists: <PlaylistMusicOutline />,
|
||||
tvshows: <Television />,
|
||||
boxsets: <MovieOutline />,
|
||||
musicvideos: <FolderMusicOutline />,
|
||||
trailers: <Youtube />,
|
||||
books: <BookMultiple />,
|
||||
photos: <ImageMultiple />,
|
||||
livetv: <TelevisionClassic />,
|
||||
folder: <FolderOutline />,
|
||||
};
|
||||
|
||||
export const MediaCollectionTypeIconCollectionCard = {
|
||||
universal: <MultiMedia className="card-image-icon" />,
|
||||
movies: <MovieOutline className="card-image-icon" />,
|
||||
music: <MusicBoxMultipleOutline className="card-image-icon" />,
|
||||
playlists: <PlaylistMusicOutline className="card-image-icon" />,
|
||||
tvshows: <Television className="card-image-icon" />,
|
||||
boxsets: <MovieOutline className="card-image-icon" />,
|
||||
musicvideos: <FolderMusicOutline className="card-image-icon" />,
|
||||
trailers: <Youtube className="card-image-icon" />,
|
||||
books: <BookMultiple className="card-image-icon" />,
|
||||
photos: <ImageMultiple className="card-image-icon" />,
|
||||
livetv: <TelevisionClassic className="card-image-icon" />,
|
||||
folder: <FolderOutline className="card-image-icon" />,
|
||||
};
|
||||
|
||||
export const MediaTypeIconCollection = {
|
||||
Video: <Filmstrip className="hero-carousel-background-icon" />,
|
||||
Audio: <Microphone className="hero-carousel-background-icon" />,
|
||||
Photo: <Image className="hero-carousel-background-icon" />,
|
||||
Book: <Book className="hero-carousel-background-icon" />,
|
||||
};
|
||||
|
||||
export const MediaTypeIconCollectionCard = {
|
||||
Video: <Filmstrip className="card-image-icon" />,
|
||||
Audio: <Microphone className="card-image-icon" />,
|
||||
Photo: <Image className="card-image-icon" />,
|
||||
Book: <Book className="card-image-icon" />,
|
||||
};
|
||||
@@ -0,0 +1,6 @@
|
||||
/** @format */
|
||||
import { EventEmitter as eventEmitter } from "events";
|
||||
|
||||
// const eventEmitter = require("events");
|
||||
|
||||
export const EventEmitter = new eventEmitter();
|
||||
@@ -0,0 +1 @@
|
||||
/** @format */
|
||||
@@ -0,0 +1,19 @@
|
||||
/** @format */
|
||||
|
||||
import React from "react";
|
||||
import ReactDOM from "react-dom/client";
|
||||
|
||||
import { BrowserRouter as Router } from "react-router-dom";
|
||||
import { CookiesProvider } from "react-cookie";
|
||||
|
||||
import App from "./App";
|
||||
|
||||
ReactDOM.createRoot(document.getElementById("root")).render(
|
||||
<React.StrictMode>
|
||||
<CookiesProvider>
|
||||
<Router>
|
||||
<App />
|
||||
</Router>
|
||||
</CookiesProvider>
|
||||
</React.StrictMode>,
|
||||
);
|
||||
@@ -0,0 +1,13 @@
|
||||
/** @format */
|
||||
/** @format */
|
||||
|
||||
@use "./styles/variables.scss" as *;
|
||||
|
||||
:export {
|
||||
clrAccentDefault: $clr-accent-default;
|
||||
clrSecondaryDefault: $clr-secondary-default;
|
||||
clrBackgroundDefault: $clr-background-default;
|
||||
|
||||
clrBackgroundDark: $clr-background-dark;
|
||||
clrBackgroundLight: $clr-background-light;
|
||||
}
|
||||
@@ -0,0 +1,99 @@
|
||||
/** @format */
|
||||
|
||||
.hero-carousel {
|
||||
position: relative;
|
||||
overflow: hidden;
|
||||
isolation: isolate;
|
||||
&-slide {
|
||||
position: relative;
|
||||
height: 70vh;
|
||||
border-radius: 10px !important;
|
||||
overflow: hidden;
|
||||
margin: 0 auto;
|
||||
}
|
||||
&-background {
|
||||
&-container {
|
||||
position: absolute;
|
||||
z-index: 0;
|
||||
top: 0;
|
||||
left: 0;
|
||||
right: 0;
|
||||
bottom: 0;
|
||||
mask-image: linear-gradient(
|
||||
to right,
|
||||
transparent 20%,
|
||||
black 50%
|
||||
);
|
||||
-webkit-mask-image: linear-gradient(
|
||||
to right,
|
||||
transparent 20%,
|
||||
rgb(0 0 0 / 0.5) 50%,
|
||||
black 90%
|
||||
);
|
||||
}
|
||||
&-image {
|
||||
position: absolute;
|
||||
background-size: cover;
|
||||
z-index: 0;
|
||||
top: 0;
|
||||
left: 0;
|
||||
right: 0;
|
||||
bottom: 0;
|
||||
}
|
||||
&-icon {
|
||||
position: absolute;
|
||||
font-size: 10em !important;
|
||||
left: 70%;
|
||||
top: 50%;
|
||||
transform: translate(-50%, -50%);
|
||||
color: $clr-accent-default;
|
||||
|
||||
&-container {
|
||||
position: absolute;
|
||||
background: $clr-accent-dark;
|
||||
z-index: 0;
|
||||
top: 0;
|
||||
left: 0;
|
||||
right: 0;
|
||||
bottom: 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
&-text {
|
||||
display: -webkit-box;
|
||||
overflow: hidden;
|
||||
-webkit-line-clamp: 2;
|
||||
}
|
||||
&-detail {
|
||||
position: relative;
|
||||
z-index: 0;
|
||||
display: flex;
|
||||
height: 70vh;
|
||||
width: 70%;
|
||||
padding: 0 2em 2em 2em;
|
||||
flex-direction: column;
|
||||
justify-content: center;
|
||||
align-items: flex-start;
|
||||
}
|
||||
&-indicator {
|
||||
width: 100%;
|
||||
height: 5px;
|
||||
border-radius: 0;
|
||||
}
|
||||
}
|
||||
|
||||
.home-section {
|
||||
&-heading {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: flex-start;
|
||||
gap: 0.35em;
|
||||
position: relative;
|
||||
margin-bottom: 0.25em !important;
|
||||
&-decoration {
|
||||
width: 0.75em;
|
||||
height: 3px;
|
||||
background: white;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,526 @@
|
||||
/** @format */
|
||||
|
||||
import { useState, useEffect } from "react";
|
||||
import { Cookies } from "react-cookie";
|
||||
|
||||
import { theme } from "../../theme";
|
||||
import "./home.module.scss";
|
||||
|
||||
import { styled } from "@mui/material/styles";
|
||||
import Box from "@mui/material/Box";
|
||||
import Skeleton from "@mui/material/Skeleton";
|
||||
import Button from "@mui/material/Button";
|
||||
import MuiAppBar from "@mui/material/AppBar";
|
||||
import MuiDrawer from "@mui/material/Drawer";
|
||||
import List from "@mui/material/List";
|
||||
import ListItem from "@mui/material/ListItem";
|
||||
import ListItemText from "@mui/material/ListItemText";
|
||||
import ListItemIcon from "@mui/material/ListItemIcon";
|
||||
import ListItemButton from "@mui/material/ListItemButton";
|
||||
import IconButton from "@mui/material/IconButton";
|
||||
import Toolbar from "@mui/material/Toolbar";
|
||||
import Divider from "@mui/material/Divider";
|
||||
import Paper from "@mui/material/Paper";
|
||||
import Typography from "@mui/material/Typography";
|
||||
import useScrollTrigger from "@mui/material/useScrollTrigger";
|
||||
|
||||
import Carousel from "react-material-ui-carousel";
|
||||
|
||||
// Custom Components
|
||||
import { CardLandscape, CardPotrait } from "../../components/card/card";
|
||||
import { CardScroller } from "../../components/cardScroller/cardScroller";
|
||||
// Icons
|
||||
import {
|
||||
MediaCollectionTypeIconCollection,
|
||||
MediaTypeIconCollection,
|
||||
} from "../../components/utils/iconsCollection.jsx";
|
||||
import MenuIcon from "mdi-material-ui/Menu";
|
||||
import Close from "mdi-material-ui/Close";
|
||||
|
||||
import { getLibraryApi } from "@jellyfin/sdk/lib/utils/api/library-api";
|
||||
import { getUserApi } from "@jellyfin/sdk/lib/utils/api/user-api";
|
||||
import { getUserLibraryApi } from "@jellyfin/sdk/lib/utils/api/user-library-api";
|
||||
|
||||
const drawerWidth = 320;
|
||||
|
||||
const openedMixin = (theme) => ({
|
||||
width: drawerWidth,
|
||||
transition: theme.transitions.create("width", {
|
||||
easing: theme.transitions.easing.sharp,
|
||||
duration: theme.transitions.duration.enteringScreen,
|
||||
}),
|
||||
overflowX: "hidden",
|
||||
});
|
||||
|
||||
const closedMixin = (theme) => ({
|
||||
transition: theme.transitions.create("width", {
|
||||
easing: theme.transitions.easing.sharp,
|
||||
duration: theme.transitions.duration.leavingScreen,
|
||||
}),
|
||||
overflowX: "hidden",
|
||||
width: `calc(${theme.spacing(7)} + 1px)`,
|
||||
[theme.breakpoints.up("sm")]: {
|
||||
width: `calc(${theme.spacing(8)} + 1px)`,
|
||||
},
|
||||
});
|
||||
|
||||
const DrawerHeader = styled("div")(({ theme }) => ({
|
||||
display: "flex",
|
||||
alignItems: "center",
|
||||
justifyContent: "flex-end",
|
||||
padding: theme.spacing(0, 1),
|
||||
// necessary for content to be below app bar
|
||||
...theme.mixins.toolbar,
|
||||
}));
|
||||
|
||||
const Drawer = styled(MuiDrawer, {
|
||||
shouldForwardProp: (prop) => prop !== "open",
|
||||
})(({ theme, open }) => ({
|
||||
width: drawerWidth,
|
||||
flexShrink: 0,
|
||||
whiteSpace: "nowrap",
|
||||
boxSizing: "border-box",
|
||||
backgroundColor: theme.palette.primary.background.dark,
|
||||
...(open && {
|
||||
...openedMixin(theme),
|
||||
"& .MuiDrawer-paper": openedMixin(theme),
|
||||
}),
|
||||
...(!open && {
|
||||
...closedMixin(theme),
|
||||
"& .MuiDrawer-paper": closedMixin(theme),
|
||||
}),
|
||||
}));
|
||||
|
||||
const AppBar = styled(MuiAppBar, {
|
||||
shouldForwardProp: (prop) => prop !== "open",
|
||||
})(({ theme, open }) => ({
|
||||
zIndex: theme.zIndex.drawer + 1,
|
||||
transition: theme.transitions.create(["width", "margin"], {
|
||||
easing: theme.transitions.easing.sharp,
|
||||
duration: theme.transitions.duration.leavingScreen,
|
||||
}),
|
||||
backgroundColor: "transparent",
|
||||
backgroundImage: "none",
|
||||
...(open && {
|
||||
marginLeft: drawerWidth,
|
||||
width: `calc(100% - ${drawerWidth}px)`,
|
||||
transition: theme.transitions.create(["width", "margin"], {
|
||||
easing: theme.transitions.easing.sharp,
|
||||
duration: theme.transitions.duration.enteringScreen,
|
||||
}),
|
||||
}),
|
||||
}));
|
||||
|
||||
export const Home = () => {
|
||||
const [skeletonStateSideMenu, setSkeletonStateSideMenu] = useState(false);
|
||||
const [skeletonStateCarousel, setSkeletonStateCarousel] = useState(false);
|
||||
|
||||
const [userLibraries, setUserLibraries] = useState([]);
|
||||
const [latestMovies, setLatestMovies] = useState([]);
|
||||
const [user, setUser] = useState({
|
||||
Name: "",
|
||||
});
|
||||
const [latestMedia, setLatestMedia] = useState([]);
|
||||
|
||||
const [drawerState, setDrawerState] = useState(false);
|
||||
const cookies = new Cookies();
|
||||
|
||||
const scrollTrigger = useScrollTrigger({ threshold: 5 });
|
||||
|
||||
const handleDrawerOpen = () => {
|
||||
setDrawerState(true);
|
||||
};
|
||||
|
||||
const handleDrawerClose = () => {
|
||||
setDrawerState(false);
|
||||
};
|
||||
|
||||
const handleLogout = async () => {
|
||||
await window.api.logout();
|
||||
console.log("logged out user");
|
||||
};
|
||||
|
||||
const currentUser = async () => {
|
||||
const user = await getUserApi(window.api).getCurrentUser();
|
||||
return user;
|
||||
};
|
||||
|
||||
const userLibs = async (user) => {
|
||||
const userLibs = await getLibraryApi(window.api).getMediaFolders();
|
||||
return userLibs;
|
||||
};
|
||||
|
||||
const getLatestMedia = async (user) => {
|
||||
const media = await getUserLibraryApi(window.api).getLatestMedia({
|
||||
userId: user.Id,
|
||||
fields: "Overview",
|
||||
enableUserData: true,
|
||||
});
|
||||
return media;
|
||||
};
|
||||
const getLatestMovies = async (user) => {
|
||||
const media = await getUserLibraryApi(window.api).getLatestMedia({
|
||||
userId: user.Id,
|
||||
fields: ["PrimaryImageAspectRatio", "Overview"],
|
||||
enableUserData: true,
|
||||
includeItemTypes: ["Movie"],
|
||||
});
|
||||
return media;
|
||||
};
|
||||
|
||||
useEffect(() => {
|
||||
currentUser().then((usr) => {
|
||||
setUser(usr.data);
|
||||
userLibs(usr.data).then((libs) => {
|
||||
setUserLibraries(libs.data.Items);
|
||||
setSkeletonStateSideMenu(true);
|
||||
// console.log(userLibraries);
|
||||
});
|
||||
getLatestMedia(usr.data).then((media) => {
|
||||
setLatestMedia(media.data);
|
||||
setSkeletonStateCarousel(true);
|
||||
});
|
||||
getLatestMovies(usr.data).then((media) => {
|
||||
setLatestMovies(media.data);
|
||||
});
|
||||
});
|
||||
for (let lib of latestMovies) {
|
||||
console.log(lib);
|
||||
}
|
||||
}, []);
|
||||
|
||||
return (
|
||||
<>
|
||||
<Box
|
||||
sx={{
|
||||
display: "flex",
|
||||
}}
|
||||
>
|
||||
<AppBar
|
||||
position="fixed"
|
||||
open={drawerState}
|
||||
color="primary"
|
||||
elevation={0}
|
||||
>
|
||||
<Toolbar>
|
||||
<IconButton
|
||||
color="inherit"
|
||||
aria-label="open drawer"
|
||||
onClick={handleDrawerOpen}
|
||||
edge="start"
|
||||
sx={{
|
||||
marginRight: 5,
|
||||
...(drawerState && { display: "none" }),
|
||||
}}
|
||||
>
|
||||
<MenuIcon />
|
||||
</IconButton>
|
||||
</Toolbar>
|
||||
</AppBar>
|
||||
|
||||
<Drawer
|
||||
variant="permanent"
|
||||
open={drawerState}
|
||||
PaperProps={{
|
||||
sx: {
|
||||
backgroundColor: "inherit",
|
||||
border: "none",
|
||||
},
|
||||
}}
|
||||
>
|
||||
<DrawerHeader
|
||||
className="Mui-DrawerHeader"
|
||||
sx={{ position: "relative", height: "20vh" }}
|
||||
>
|
||||
{/* <div>
|
||||
<Avatar src={""}/>
|
||||
<Typography variant="h3">
|
||||
{user["Name"]}
|
||||
</Typography>
|
||||
</div> */}
|
||||
<IconButton
|
||||
onClick={handleDrawerClose}
|
||||
sx={{
|
||||
position: "absolute",
|
||||
top: "10%",
|
||||
right: "5%",
|
||||
opacity: drawerState ? 1 : 0,
|
||||
}}
|
||||
>
|
||||
<Close />
|
||||
</IconButton>
|
||||
</DrawerHeader>
|
||||
<Divider />
|
||||
{skeletonStateSideMenu ? (
|
||||
<List sx={{ border: "none" }}>
|
||||
{userLibraries.map((library, index) => {
|
||||
return (
|
||||
<ListItem
|
||||
disablePadding
|
||||
key={index}
|
||||
>
|
||||
<ListItemButton
|
||||
sx={{
|
||||
minHeight: 48,
|
||||
justifyContent:
|
||||
drawerState
|
||||
? "initial"
|
||||
: "center",
|
||||
px: 2.5,
|
||||
}}
|
||||
>
|
||||
<ListItemIcon
|
||||
sx={{
|
||||
minWidth: 0,
|
||||
mr: drawerState
|
||||
? 3
|
||||
: "auto",
|
||||
justifyContent:
|
||||
"center",
|
||||
}}
|
||||
>
|
||||
{
|
||||
MediaCollectionTypeIconCollection[
|
||||
library
|
||||
.CollectionType
|
||||
]
|
||||
}
|
||||
</ListItemIcon>
|
||||
<ListItemText
|
||||
primary={
|
||||
library.Name
|
||||
}
|
||||
sx={{
|
||||
opacity: drawerState
|
||||
? 1
|
||||
: 0,
|
||||
}}
|
||||
/>
|
||||
</ListItemButton>
|
||||
</ListItem>
|
||||
);
|
||||
})}
|
||||
</List>
|
||||
) : (
|
||||
<>
|
||||
<Skeleton
|
||||
height={50}
|
||||
variant="rectangular"
|
||||
animation="wave"
|
||||
></Skeleton>
|
||||
<br />
|
||||
<Skeleton
|
||||
height={50}
|
||||
variant="rectangular"
|
||||
animation="wave"
|
||||
></Skeleton>
|
||||
<br />
|
||||
<Skeleton
|
||||
height={50}
|
||||
variant="rectangular"
|
||||
animation="wave"
|
||||
></Skeleton>
|
||||
</>
|
||||
)}
|
||||
</Drawer>
|
||||
{/* <h1>Hey {userId} this is WIP Home</h1> */}
|
||||
<Box
|
||||
component="main"
|
||||
className="scrollY"
|
||||
sx={{ flexGrow: 1, p: 3 }}
|
||||
>
|
||||
<DrawerHeader />
|
||||
<Carousel
|
||||
className="hero-carousel"
|
||||
autoPlay={true}
|
||||
animation="fade"
|
||||
height="70vh"
|
||||
IndicatorIcon={
|
||||
<div className="hero-carousel-indicator"></div>
|
||||
}
|
||||
activeIndicatorIconButtonProps={{
|
||||
style: {
|
||||
background: "rgb(255 255 255)",
|
||||
},
|
||||
}}
|
||||
indicatorIconButtonProps={{
|
||||
style: {
|
||||
background: "rgb(255 255 255 / 0.3)",
|
||||
borderRadius: "2px",
|
||||
width: "100%",
|
||||
flexShrink: "1",
|
||||
},
|
||||
}}
|
||||
indicatorContainerProps={{
|
||||
style: {
|
||||
display: "flex",
|
||||
gap: "1em",
|
||||
},
|
||||
}}
|
||||
sx={{
|
||||
marginBottom: "1.5em",
|
||||
}}
|
||||
interval={10000}
|
||||
>
|
||||
{skeletonStateCarousel ? (
|
||||
latestMedia.map((item, index) => {
|
||||
// console.log(item);
|
||||
return (
|
||||
<Paper
|
||||
className="hero-carousel-slide"
|
||||
sx={{
|
||||
background:
|
||||
theme.palette
|
||||
.primary
|
||||
.background
|
||||
.dark,
|
||||
}}
|
||||
key={index}
|
||||
>
|
||||
<div className="hero-carousel-background-container">
|
||||
{item.ImageBlurHashes
|
||||
.Backdrop ? (
|
||||
<div
|
||||
className="hero-carousel-background-image"
|
||||
style={{
|
||||
backgroundImage: `url(${
|
||||
window
|
||||
.api
|
||||
.basePath +
|
||||
"/Items/" +
|
||||
item.Id +
|
||||
"/Images/Backdrop"
|
||||
})`,
|
||||
}}
|
||||
></div>
|
||||
) : (
|
||||
<div className="hero-carousel-background-image empty"></div>
|
||||
)}
|
||||
<div className="hero-carousel-background-icon-container">
|
||||
{
|
||||
MediaTypeIconCollection[
|
||||
item
|
||||
.MediaType
|
||||
]
|
||||
}
|
||||
</div>
|
||||
</div>
|
||||
<Box className="hero-carousel-detail">
|
||||
<Typography
|
||||
variant="h3"
|
||||
className="hero-carousel-text"
|
||||
>
|
||||
{item.Name}
|
||||
</Typography>
|
||||
<Typography
|
||||
variant="subtitle1"
|
||||
className="hero-carousel-text"
|
||||
>
|
||||
{item.Overview}
|
||||
</Typography>
|
||||
</Box>
|
||||
</Paper>
|
||||
);
|
||||
})
|
||||
) : (
|
||||
<Paper
|
||||
className="hero-carousel-slide"
|
||||
sx={{
|
||||
background:
|
||||
theme.palette.primary
|
||||
.background.dark,
|
||||
}}
|
||||
>
|
||||
<div className="hero-carousel-background">
|
||||
<Skeleton
|
||||
variant="rectangular"
|
||||
height="100%"
|
||||
animation="wave"
|
||||
></Skeleton>
|
||||
</div>
|
||||
<Box className="hero-carousel-detail">
|
||||
<Typography
|
||||
variant="h3"
|
||||
className="hero-carousel-text"
|
||||
>
|
||||
<Skeleton
|
||||
variant="text"
|
||||
sx={{ fontSize: "5rem" }}
|
||||
width={300}
|
||||
animation="wave"
|
||||
></Skeleton>
|
||||
</Typography>
|
||||
<Typography
|
||||
variant="p"
|
||||
className="hero-carousel-text"
|
||||
>
|
||||
<Skeleton
|
||||
variant="text"
|
||||
sx={{ fontSize: "3rem" }}
|
||||
width={400}
|
||||
animation="wave"
|
||||
></Skeleton>
|
||||
</Typography>
|
||||
</Box>
|
||||
</Paper>
|
||||
)}
|
||||
</Carousel>
|
||||
|
||||
<Box className="home-section">
|
||||
<Typography
|
||||
variant="h4"
|
||||
color="textPrimary"
|
||||
className="home-section-heading"
|
||||
>
|
||||
<div className="home-section-heading-decoration"></div>{" "}
|
||||
Libraries
|
||||
</Typography>
|
||||
<CardScroller displayCards={4}>
|
||||
{userLibraries.map((library, index) => {
|
||||
return (
|
||||
<CardLandscape
|
||||
key={index}
|
||||
itemName={library.Name}
|
||||
itemId={library.Id}
|
||||
imageTags={library.imageTags}
|
||||
iconType={
|
||||
library.CollectionType
|
||||
}
|
||||
></CardLandscape>
|
||||
);
|
||||
})}
|
||||
</CardScroller>
|
||||
</Box>
|
||||
|
||||
<Box className="home-section">
|
||||
<Typography
|
||||
variant="h4"
|
||||
color="textPrimary"
|
||||
className="home-section-heading"
|
||||
>
|
||||
<div className="home-section-heading-decoration"></div>{" "}
|
||||
Latest Movies
|
||||
</Typography>
|
||||
<CardScroller displayCards={7}>
|
||||
{latestMovies.map((movie, index) => {
|
||||
return (
|
||||
<CardPotrait
|
||||
key={index}
|
||||
itemName={movie.Name}
|
||||
itemId={movie.Id}
|
||||
imageTags={movie.imageTags}
|
||||
iconType={movie.MediaType}
|
||||
></CardPotrait>
|
||||
);
|
||||
})}
|
||||
</CardScroller>
|
||||
</Box>
|
||||
|
||||
<Button variant="contained" onClick={handleLogout}>
|
||||
Logout
|
||||
</Button>
|
||||
</Box>
|
||||
</Box>
|
||||
</>
|
||||
);
|
||||
};
|
||||
@@ -0,0 +1,30 @@
|
||||
/** @format */
|
||||
|
||||
.user {
|
||||
&List {
|
||||
display: flex;
|
||||
gap: 1em;
|
||||
width: min(60vw, 45em);
|
||||
}
|
||||
&Card {
|
||||
display: flex;
|
||||
flex-flow: column;
|
||||
flex: 1 1 0px;
|
||||
}
|
||||
&Icon {
|
||||
font-size: 5em;
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
background: $clr-accent-dark;
|
||||
}
|
||||
}
|
||||
|
||||
.buttons {
|
||||
display: flex;
|
||||
gap: 1em;
|
||||
width: 100%;
|
||||
.userEventButton {
|
||||
flex: 1 1 0 !important;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,390 @@
|
||||
/** @format */
|
||||
|
||||
import { useState, useEffect } from "react";
|
||||
import { Cookies, useCookies } from "react-cookie";
|
||||
import { useNavigate, useParams, Link } from "react-router-dom";
|
||||
import { EventEmitter as event } from "../../eventEmitter.js";
|
||||
import { motion } from "framer-motion";
|
||||
|
||||
// import Icon from "mdi-material-ui";
|
||||
import EyeOffOutline from "mdi-material-ui/EyeOffOutline";
|
||||
import EyeOutline from "mdi-material-ui/EyeOutline";
|
||||
import ChevronRight from "mdi-material-ui/ChevronRight";
|
||||
|
||||
import Container from "@mui/material/Container";
|
||||
import Grid from "@mui/material/Grid";
|
||||
import Typography from "@mui/material/Typography";
|
||||
import OutlinedInput from "@mui/material/OutlinedInput";
|
||||
import FormControl from "@mui/material/FormControl";
|
||||
import InputAdornment from "@mui/material/InputAdornment";
|
||||
import InputLabel from "@mui/material/InputLabel";
|
||||
import IconButton from "@mui/material/IconButton";
|
||||
import Avatar from "@mui/material/Avatar";
|
||||
import LoadingButton from "@mui/lab/LoadingButton";
|
||||
import Button from "@mui/material/Button";
|
||||
import { useSnackbar } from "notistack";
|
||||
|
||||
import { AvatarCard, AvatarImage } from "../../components/avatar/avatar.jsx";
|
||||
import { AppBarBackOnly } from "../../components/appBar/backOnly.jsx";
|
||||
|
||||
// import { jellyfin } from "../../jellyfin";
|
||||
// import getSystemApi from "@jellyfin/sdk";
|
||||
import { getUserApi } from "@jellyfin/sdk/lib/utils/api/user-api";
|
||||
|
||||
import "./login.module.scss";
|
||||
|
||||
export const LoginWithImage = () => {
|
||||
const { userName, userId } = useParams();
|
||||
const [password, setPassword] = useState({
|
||||
showpass: false,
|
||||
});
|
||||
const [loading, setLoading] = useState(false);
|
||||
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) {
|
||||
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);
|
||||
event.emit("set-api-accessToken", window.api.basePath);
|
||||
// setAccessToken(user.data.AccessToken)
|
||||
setLoading(false);
|
||||
navigate(`/home`);
|
||||
};
|
||||
|
||||
return (
|
||||
<>
|
||||
<AppBarBackOnly />
|
||||
<Container maxWidth="xs" className="centered">
|
||||
<Grid
|
||||
container
|
||||
direction="column"
|
||||
justifyContent="center"
|
||||
alignItems="center"
|
||||
spacing={2}
|
||||
>
|
||||
<Grid item marginBottom={2}>
|
||||
<Typography
|
||||
textAlign="center"
|
||||
variant="h3"
|
||||
color="textPrimary"
|
||||
>
|
||||
Login
|
||||
<br />
|
||||
</Typography>
|
||||
</Grid>
|
||||
<Grid item>
|
||||
<AvatarImage userId={userId} />
|
||||
<Typography
|
||||
color="textPrimary"
|
||||
textAlign="center"
|
||||
variant="h4"
|
||||
>
|
||||
{userName}
|
||||
</Typography>
|
||||
</Grid>
|
||||
<Grid item minWidth="100%">
|
||||
<br />
|
||||
<FormControl variant="outlined" fullWidth>
|
||||
<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 ? (
|
||||
<EyeOffOutline />
|
||||
) : (
|
||||
<EyeOutline />
|
||||
)}
|
||||
</IconButton>
|
||||
</InputAdornment>
|
||||
}
|
||||
/>
|
||||
</FormControl>
|
||||
</Grid>
|
||||
<Grid item minWidth="100%">
|
||||
<LoadingButton
|
||||
variant="contained"
|
||||
endIcon={<ChevronRight />}
|
||||
onClick={handleLogin}
|
||||
loading={loading}
|
||||
loadingPosition="end"
|
||||
size="large"
|
||||
fullWidth
|
||||
>
|
||||
Login
|
||||
</LoadingButton>
|
||||
</Grid>
|
||||
</Grid>
|
||||
</Container>
|
||||
</>
|
||||
);
|
||||
};
|
||||
|
||||
export const UserLogin = () => {
|
||||
const [userList, setUsers] = useState([]);
|
||||
const navigate = useNavigate();
|
||||
const cookies = new Cookies();
|
||||
|
||||
const currentServer = cookies.get("currentServer");
|
||||
const serverList = cookies.get("servers");
|
||||
|
||||
const handleChangeServer = () => {
|
||||
navigate("/servers/list");
|
||||
};
|
||||
const handleManualLogin = () => {
|
||||
navigate("/login/manual");
|
||||
};
|
||||
const getUsers = async () => {
|
||||
const users = await getUserApi(window.api).getPublicUsers();
|
||||
// console.log(users.data);
|
||||
return users;
|
||||
// return {};
|
||||
};
|
||||
useEffect(() => {
|
||||
getUsers().then((users) => {
|
||||
setUsers(users.data);
|
||||
});
|
||||
});
|
||||
|
||||
return (
|
||||
<>
|
||||
<AppBarBackOnly />
|
||||
<Container maxWidth="md" className="centered">
|
||||
<h1 color="white">WIP-user login</h1>
|
||||
<div className="userList">
|
||||
{userList.map((item, index) => {
|
||||
return (
|
||||
//
|
||||
<Link
|
||||
to={`/login/withImg/${item.Name}/${item.Id}/`}
|
||||
key={item.Id}
|
||||
className="userCard"
|
||||
index={index}
|
||||
>
|
||||
{item.ImageTags == undefined ? (
|
||||
<AvatarCard
|
||||
userName={item.Name}
|
||||
userId={item.Id}
|
||||
userImageAvailable={false}
|
||||
></AvatarCard>
|
||||
) : (
|
||||
<AvatarCard
|
||||
userName={item.Name}
|
||||
userImageAvailable={true}
|
||||
></AvatarCard>
|
||||
)}
|
||||
</Link>
|
||||
);
|
||||
})}
|
||||
</div>
|
||||
<div className="buttons">
|
||||
<Button
|
||||
color="secondary"
|
||||
variant="contained"
|
||||
className="userEventButton"
|
||||
onClick={handleChangeServer}
|
||||
>
|
||||
Change Server
|
||||
</Button>
|
||||
<Button
|
||||
variant="contained"
|
||||
className="userEventButton"
|
||||
onClick={handleManualLogin}
|
||||
>
|
||||
Manual Login
|
||||
</Button>
|
||||
</div>
|
||||
</Container>
|
||||
</>
|
||||
);
|
||||
};
|
||||
|
||||
export const UserLoginManual = () => {
|
||||
const [loading, setLoading] = useState(false);
|
||||
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);
|
||||
event.emit("set-api-accessToken", window.api.basePath);
|
||||
// setAccessToken(user.data.AccessToken)
|
||||
setLoading(false);
|
||||
navigate(`/home`);
|
||||
};
|
||||
|
||||
return (
|
||||
<>
|
||||
<AppBarBackOnly />
|
||||
<Container maxWidth="xs" className="centered">
|
||||
<Grid
|
||||
container
|
||||
spacing={2}
|
||||
direction="column"
|
||||
justifyContent="center"
|
||||
alignItems="center"
|
||||
>
|
||||
<Grid item xl={5} md={6} sx={{ marginBottom: "1em" }}>
|
||||
<Typography variant="h3" color="textPrimary">
|
||||
Login
|
||||
</Typography>
|
||||
</Grid>
|
||||
<Grid sx={{ width: "100%" }} item xl={5} md={6}>
|
||||
<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%" }} item xl={5} md={6}>
|
||||
<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")}
|
||||
label="Password:"
|
||||
endAdornment={
|
||||
<InputAdornment position="end">
|
||||
<IconButton
|
||||
onClick={
|
||||
handleShowPassword
|
||||
}
|
||||
aria-label="toggle password visibility"
|
||||
>
|
||||
{password.showpass ? (
|
||||
<EyeOffOutline />
|
||||
) : (
|
||||
<EyeOutline />
|
||||
)}
|
||||
</IconButton>
|
||||
</InputAdornment>
|
||||
}
|
||||
/>
|
||||
</FormControl>
|
||||
</Grid>
|
||||
<Grid item xl={5} md={6} sx={{ width: "100%" }}>
|
||||
<LoadingButton
|
||||
variant="contained"
|
||||
endIcon={<ChevronRight />}
|
||||
onClick={handleLogin}
|
||||
loading={loading}
|
||||
loadingPosition="end"
|
||||
size="large"
|
||||
sx={{ width: "100%" }}
|
||||
>
|
||||
Login
|
||||
</LoadingButton>
|
||||
</Grid>
|
||||
</Grid>
|
||||
</Container>
|
||||
</>
|
||||
);
|
||||
};
|
||||
@@ -0,0 +1,238 @@
|
||||
/** @format */
|
||||
|
||||
import { useState, useEffect } from "react";
|
||||
import { Cookies, useCookies } from "react-cookie";
|
||||
import { Navigate } from "react-router-dom";
|
||||
import { v4 as uuidv4 } from "uuid";
|
||||
|
||||
import { EventEmitter as event } from "../../../eventEmitter.js";
|
||||
import { getSystemApi } from "@jellyfin/sdk/lib/utils/api/system-api";
|
||||
|
||||
// MUI
|
||||
import TextField from "@mui/material/TextField";
|
||||
import Typography from "@mui/material/Typography";
|
||||
import Grid from "@mui/material/Grid";
|
||||
import ListItem from "@mui/material/ListItem";
|
||||
import ListItemText from "@mui/material/ListItemText";
|
||||
import Button from "@mui/material/Button";
|
||||
import LinearProgress from "@mui/material/LinearProgress";
|
||||
import Container from "@mui/material/Container";
|
||||
import { useSnackbar } from "notistack";
|
||||
|
||||
// Svgs
|
||||
import { ReactComponent as JellyplayerLogo } from "../../../assets/logo.svg";
|
||||
|
||||
// SCSS
|
||||
import "./server.module.scss";
|
||||
|
||||
export const ServerList = () => {
|
||||
const [renderServerList, setRenderServerList] = useState(false);
|
||||
const [serverListRender, setServerListRender] = useState([]);
|
||||
const cookies = new Cookies();
|
||||
|
||||
const currentServer = cookies.get("currentServer");
|
||||
const serverList = cookies.get("servers");
|
||||
let currentServerIp = "";
|
||||
serverList.map((item, index) => {
|
||||
currentServerIp = item[currentServer];
|
||||
// console.log(item);
|
||||
});
|
||||
|
||||
const createServerListRender = async () => {
|
||||
let serverListKeys = [];
|
||||
serverList.map((item, index) => {
|
||||
serverListKeys.push(Object.keys(item));
|
||||
// for (let item in servers) {
|
||||
// if (item != "currentServer") {
|
||||
// setServerList([...serverList, JSON.parse(servers[item])]);
|
||||
// serverList.push(JSON.parse(servers[item]));
|
||||
// }
|
||||
// }
|
||||
});
|
||||
return serverListKeys;
|
||||
// console.log(serverListRender);
|
||||
// localStorage.setItem("servers", serverList);
|
||||
};
|
||||
|
||||
const ServerList = (props) => {
|
||||
const startRender = props.startRender;
|
||||
if (startRender) {
|
||||
return serverList.map((item, index) => {
|
||||
let serverIndex = serverListRender[index];
|
||||
let itm = item[serverIndex];
|
||||
console.log(itm.serverAddress);
|
||||
console.log("serverIndex : ", serverIndex);
|
||||
|
||||
return (
|
||||
<div
|
||||
key={index}
|
||||
className="server"
|
||||
style={{ color: "white" }}
|
||||
>
|
||||
{/* <Typography></Typography> */}
|
||||
hello {itm.serverAddress} This is WIP
|
||||
</div>
|
||||
);
|
||||
});
|
||||
} else if (!startRender) {
|
||||
return <h1>Hfjsi</h1>;
|
||||
}
|
||||
};
|
||||
// const serverList = createServerList();
|
||||
useEffect(() => {
|
||||
createServerListRender().then((serverListKeys) => {
|
||||
console.log("ServerListKeys : ", serverListKeys);
|
||||
setServerListRender(serverListKeys);
|
||||
setRenderServerList(true);
|
||||
});
|
||||
// console.log(serverList);
|
||||
}, []);
|
||||
return (
|
||||
<>
|
||||
<Container maxWidth="md" className="centered">
|
||||
<Typography color="textPrimary" variant="h3">
|
||||
Select Server:
|
||||
</Typography>
|
||||
<div className="serverList">
|
||||
<ServerList
|
||||
startRender={renderServerList}
|
||||
></ServerList>
|
||||
{/*
|
||||
{serverList.map((item, index) => {
|
||||
// let serverIndex = serverListRender[index];
|
||||
// let itm = item[serverIndex];
|
||||
// console.log(itm.serverAddress);
|
||||
// console.log("serverIndex : ", serverIndex);
|
||||
return (
|
||||
// <></>
|
||||
<div key={index} className="server">
|
||||
hello{" "}
|
||||
{
|
||||
item[serverListRender[index]]
|
||||
.serverAddress
|
||||
}{" "}
|
||||
</div>
|
||||
);
|
||||
})} */}
|
||||
</div>
|
||||
</Container>
|
||||
</>
|
||||
);
|
||||
};
|
||||
|
||||
export const ServerSetup = (props) => {
|
||||
const [serverIp, setServerIp] = useState("");
|
||||
const [checkingServer, setServerCheckState] = useState(false);
|
||||
const [isJfServer, setIsJfServerState] = useState(false);
|
||||
|
||||
const { enqueueSnackbar } = useSnackbar();
|
||||
const [serverlistCookies, setServerList] = useCookies(["servers"]);
|
||||
const [currentServer, setCurrentServer] = useCookies(["currentServer"]);
|
||||
const cookies = new Cookies();
|
||||
|
||||
const addServer = async () => {
|
||||
event.emit("create-jellyfin-api", serverIp);
|
||||
let sysInfo = await getSystemApi(window.api).getPublicSystemInfo();
|
||||
sysInfo = sysInfo.data;
|
||||
let initServerList = cookies.get("servers");
|
||||
if (initServerList == null) {
|
||||
initServerList = [];
|
||||
} else {
|
||||
initServerList = JSON.parse(initServerList);
|
||||
}
|
||||
let serverConf = {
|
||||
serverName: sysInfo.ServerName,
|
||||
id: sysInfo.Id,
|
||||
jellyfinVersion: sysInfo.Version,
|
||||
serverAddress: serverIp,
|
||||
};
|
||||
let jfId = sysInfo.Id;
|
||||
let server = {};
|
||||
server[sysInfo.Id] = serverConf;
|
||||
server = JSON.stringify([...initServerList, server]);
|
||||
setServerList("servers", server, { path: "/" });
|
||||
setCurrentServer("currentServer", sysInfo.Id, { path: "/" });
|
||||
setIsJfServerState(true);
|
||||
};
|
||||
|
||||
const handleAddServer = () => {
|
||||
let data;
|
||||
setServerCheckState(true);
|
||||
fetch(`${serverIp}/System/Ping`, {
|
||||
body: JSON.stringify(data),
|
||||
})
|
||||
.then((res) => res.json())
|
||||
.then((data) => {
|
||||
if (data == "Jellyfin Server") {
|
||||
console.log(true);
|
||||
setServerCheckState(false);
|
||||
addServer();
|
||||
return true;
|
||||
} else {
|
||||
setServerCheckState(false);
|
||||
enqueueSnackbar(
|
||||
"The server address does not seem be a jellyfin server",
|
||||
{ variant: "error" },
|
||||
);
|
||||
return false;
|
||||
}
|
||||
})
|
||||
.catch((error) => {
|
||||
setServerCheckState(false);
|
||||
enqueueSnackbar(
|
||||
"Unable to verify whether the give address is a valid Jellyfin server",
|
||||
{ variant: "error" },
|
||||
);
|
||||
console.error(error);
|
||||
});
|
||||
};
|
||||
|
||||
return (
|
||||
<>
|
||||
{checkingServer && <LinearProgress />}
|
||||
{isJfServer && <Navigate to="/login" />}
|
||||
<Container
|
||||
maxWidth="md"
|
||||
className={
|
||||
checkingServer
|
||||
? "centered serverContainer loading"
|
||||
: "centered serverContainer"
|
||||
}
|
||||
>
|
||||
<Grid
|
||||
container
|
||||
spacing={2}
|
||||
direction="column"
|
||||
justifyContent="center"
|
||||
alignItems="center"
|
||||
>
|
||||
<Grid item xl={5} md={6} sx={{ marginBottom: "1em" }}>
|
||||
<JellyplayerLogo className="logo" />
|
||||
</Grid>
|
||||
<Grid item xl={5} md={6} sx={{ width: "100%" }}>
|
||||
<TextField
|
||||
className="textbox"
|
||||
label="Server Address:"
|
||||
variant="outlined"
|
||||
// inputRef={serverIp}
|
||||
onChange={(event) => {
|
||||
setServerIp(event.target.value);
|
||||
}}
|
||||
helperText="Add your server adddress with https:// or http://"
|
||||
></TextField>
|
||||
</Grid>
|
||||
<Grid item xl={5} md={6} sx={{ width: "100%" }}>
|
||||
<Button
|
||||
variant="contained"
|
||||
sx={{ width: "100%" }}
|
||||
size="large"
|
||||
onClick={handleAddServer}
|
||||
>
|
||||
Add Server
|
||||
</Button>
|
||||
</Grid>
|
||||
</Grid>
|
||||
</Container>
|
||||
</>
|
||||
);
|
||||
};
|
||||
@@ -0,0 +1,22 @@
|
||||
/** @format */
|
||||
.logo {
|
||||
width: min(60vw, 45em);
|
||||
height: auto;
|
||||
margin-bottom: 2em;
|
||||
}
|
||||
|
||||
.serverContainer {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
gap: 1.5em;
|
||||
.textbox,
|
||||
.button {
|
||||
width: 100% !important;
|
||||
}
|
||||
.button {
|
||||
padding: 1em;
|
||||
border-radius: 100px;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,73 @@
|
||||
/** @format */
|
||||
body {
|
||||
font-family: "Open Sans";
|
||||
background: $clr-background-default;
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
position: relative;
|
||||
width: 100vw;
|
||||
height: 100vh;
|
||||
}
|
||||
|
||||
#root,
|
||||
.root-page {
|
||||
height: 100vh;
|
||||
width: 100vw;
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
.centered {
|
||||
position: absolute;
|
||||
top: 50%;
|
||||
left: 50%;
|
||||
transform: translate(-50%, -50%);
|
||||
}
|
||||
|
||||
.loading {
|
||||
opacity: 0.35;
|
||||
}
|
||||
|
||||
.fadeIn {
|
||||
animation: 0.5s fadeIn forwards;
|
||||
}
|
||||
|
||||
.fadeOut {
|
||||
animation: 0.5s fadeOut forwards;
|
||||
}
|
||||
|
||||
@keyframes fadeIn {
|
||||
from {
|
||||
opacity: 0;
|
||||
transform: translate(-20px, 0);
|
||||
}
|
||||
to {
|
||||
opacity: 1;
|
||||
transform: translate(0px, 0px);
|
||||
}
|
||||
}
|
||||
|
||||
@keyframes fadeOut {
|
||||
from {
|
||||
opacity: 1;
|
||||
transform: translate(0px, 0px);
|
||||
}
|
||||
to {
|
||||
transform: translate(20px, 0);
|
||||
opacity: 0;
|
||||
}
|
||||
}
|
||||
|
||||
h1 {
|
||||
color: white !important;
|
||||
}
|
||||
|
||||
.scrollY {
|
||||
overflow-x: hidden;
|
||||
overflow-y: auto;
|
||||
height: 100vh;
|
||||
box-sizing: border-box;
|
||||
}
|
||||
|
||||
.empty {
|
||||
display: none;
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
/** @format */
|
||||
|
||||
$clr-accent-default: hsl(337, 96%, 56%);
|
||||
$clr-accent-dark: hsl(337, 96%, 10%);
|
||||
$clr-secondary-default: hsl(273, 100%, 22%);
|
||||
$clr-background-default: hsl(256, 100%, 6%);
|
||||
|
||||
$clr-background-dark: hsl(256, 100%, 4%);
|
||||
$clr-background-light: hsl(256, 100%, 16%);
|
||||
|
||||
$border-radius-default: 10px;
|
||||
$border-radius-intensity-1: 5px;
|
||||
|
||||
$transition-time-default: 250ms;
|
||||
@@ -0,0 +1,39 @@
|
||||
/** @format */
|
||||
|
||||
import { createTheme } from "@mui/material/styles";
|
||||
import {
|
||||
clrAccentDefault,
|
||||
clrBackgroundDefault,
|
||||
clrBackgroundDark,
|
||||
clrBackgroundLight,
|
||||
clrSecondaryDefault,
|
||||
} from "./palette.module.scss";
|
||||
|
||||
export const theme = createTheme({
|
||||
palette: {
|
||||
primary: {
|
||||
main: clrAccentDefault,
|
||||
background: {
|
||||
main: clrBackgroundDefault,
|
||||
light: clrBackgroundLight,
|
||||
dark: clrBackgroundDark,
|
||||
},
|
||||
},
|
||||
secondary: {
|
||||
main: clrSecondaryDefault,
|
||||
},
|
||||
mode: "dark",
|
||||
},
|
||||
typography: {
|
||||
fontFamily: "Open Sans",
|
||||
},
|
||||
components: {
|
||||
MuiButton: {
|
||||
styleOverrides: {
|
||||
root: {
|
||||
borderRadius: "100px",
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
});
|
||||
Reference in new issue
Block a user