Add sqaure cards #24, fix cards in login page
This commit is contained in:
7 files changed
+83
-146
No files matched your search
+22
-8
@@ -3,7 +3,6 @@
|
|||||||
import React, { useState, Suspense } from "react";
|
import React, { useState, Suspense } from "react";
|
||||||
import { ThemeProvider } from "@mui/material/styles";
|
import { ThemeProvider } from "@mui/material/styles";
|
||||||
import { SnackbarProvider } from "notistack";
|
import { SnackbarProvider } from "notistack";
|
||||||
import { useCookies, Cookies } from "react-cookie";
|
|
||||||
import {
|
import {
|
||||||
Routes,
|
Routes,
|
||||||
Route,
|
Route,
|
||||||
@@ -118,12 +117,16 @@ const AnimationWrapper = () => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
function App() {
|
function App() {
|
||||||
const [userCookies] = useCookies(["user"]);
|
|
||||||
const navigate = useNavigate();
|
const navigate = useNavigate();
|
||||||
|
|
||||||
const [serverReachable, setServerReachable] = useState(true);
|
const [serverReachable, setServerReachable] = useState(true);
|
||||||
const [checkingServer, setChecking] = useState(false);
|
const [checkingServer, setChecking] = useState(false);
|
||||||
|
|
||||||
|
const createApi = async () => {
|
||||||
|
const server = await getServer();
|
||||||
|
event.emit("create-jellyfin-api", server.Ip);
|
||||||
|
};
|
||||||
|
|
||||||
const serverAvailable = async () => {
|
const serverAvailable = async () => {
|
||||||
const server = await getServer();
|
const server = await getServer();
|
||||||
|
|
||||||
@@ -131,10 +134,10 @@ function App() {
|
|||||||
console.log("server not found");
|
console.log("server not found");
|
||||||
return false;
|
return false;
|
||||||
} else {
|
} else {
|
||||||
if (!window.api) {
|
// if (!window.api) {
|
||||||
console.log("Creating Jf api (without accessToken)");
|
// console.log("Creating Jf api (without accessToken)");
|
||||||
event.emit("create-jellyfin-api", server.Ip);
|
// event.emit("create-jellyfin-api", server.Ip);
|
||||||
}
|
// }
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@@ -194,7 +197,7 @@ function App() {
|
|||||||
sessionStorage.setItem("accessToken", auth.data.AccessToken);
|
sessionStorage.setItem("accessToken", auth.data.AccessToken);
|
||||||
event.emit("set-api-accessToken", window.api.basePath);
|
event.emit("set-api-accessToken", window.api.basePath);
|
||||||
|
|
||||||
navigate("/home");
|
// navigate("/home");
|
||||||
};
|
};
|
||||||
|
|
||||||
const LogicalRoutes = () => {
|
const LogicalRoutes = () => {
|
||||||
@@ -204,7 +207,7 @@ function App() {
|
|||||||
if (serverReachable == true) {
|
if (serverReachable == true) {
|
||||||
userSaved().then((user_available) => {
|
userSaved().then((user_available) => {
|
||||||
if (user_available == true) {
|
if (user_available == true) {
|
||||||
userLogin();
|
navigate("/home");
|
||||||
} else {
|
} else {
|
||||||
usersAvailable().then(
|
usersAvailable().then(
|
||||||
(users_list_available) => {
|
(users_list_available) => {
|
||||||
@@ -244,6 +247,17 @@ function App() {
|
|||||||
};
|
};
|
||||||
const location = useLocation();
|
const location = useLocation();
|
||||||
|
|
||||||
|
if (!window.api) {
|
||||||
|
console.log("WindowAPi not present");
|
||||||
|
createApi().then(
|
||||||
|
userSaved().then((userSavedBool) => {
|
||||||
|
if (userSavedBool) {
|
||||||
|
userLogin();
|
||||||
|
}
|
||||||
|
}),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<SnackbarProvider maxSnack={5}>
|
<SnackbarProvider maxSnack={5}>
|
||||||
<ThemeProvider theme={theme}>
|
<ThemeProvider theme={theme}>
|
||||||
|
|||||||
@@ -49,7 +49,9 @@ export const Card = ({
|
|||||||
aspectRatio:
|
aspectRatio:
|
||||||
cardOrientation == "landscape"
|
cardOrientation == "landscape"
|
||||||
? "1.777"
|
? "1.777"
|
||||||
: "0.666",
|
: cardOrientation == "portait"
|
||||||
|
? "0.666"
|
||||||
|
: "1",
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
{imageTags &&
|
{imageTags &&
|
||||||
@@ -68,7 +70,10 @@ export const Card = ({
|
|||||||
aspectRatio:
|
aspectRatio:
|
||||||
cardOrientation == "landscape"
|
cardOrientation == "landscape"
|
||||||
? "1.777"
|
? "1.777"
|
||||||
: "0.666",
|
: cardOrientation ==
|
||||||
|
"portait"
|
||||||
|
? "0.666"
|
||||||
|
: "1",
|
||||||
}}
|
}}
|
||||||
className="card-image"
|
className="card-image"
|
||||||
></CardMedia>
|
></CardMedia>
|
||||||
@@ -87,7 +92,10 @@ export const Card = ({
|
|||||||
aspectRatio:
|
aspectRatio:
|
||||||
cardOrientation == "landscape"
|
cardOrientation == "landscape"
|
||||||
? "1.777"
|
? "1.777"
|
||||||
: "0.666",
|
: cardOrientation ==
|
||||||
|
"portait"
|
||||||
|
? "0.666"
|
||||||
|
: "1",
|
||||||
}}
|
}}
|
||||||
className="card-image"
|
className="card-image"
|
||||||
></CardMedia>
|
></CardMedia>
|
||||||
|
|||||||
@@ -60,7 +60,11 @@ export const LatestMediaSection = ({ latestMediaLib }) => {
|
|||||||
playedPercent={
|
playedPercent={
|
||||||
item.UserData.PlayedPercentage
|
item.UserData.PlayedPercentage
|
||||||
}
|
}
|
||||||
cardOrientation="portait"
|
cardOrientation={
|
||||||
|
item.PrimaryImageAspectRatio == 1
|
||||||
|
? "sqaure"
|
||||||
|
: "portait"
|
||||||
|
}
|
||||||
></Card>
|
></Card>
|
||||||
);
|
);
|
||||||
})}
|
})}
|
||||||
|
|||||||
@@ -69,7 +69,7 @@ const Home = () => {
|
|||||||
event.emit("set-api-accessToken", window.api.basePath);
|
event.emit("set-api-accessToken", window.api.basePath);
|
||||||
return true;
|
return true;
|
||||||
},
|
},
|
||||||
enabled: !window.api,
|
enabled: false,
|
||||||
});
|
});
|
||||||
|
|
||||||
const user = useQuery({
|
const user = useQuery({
|
||||||
@@ -633,7 +633,7 @@ const Home = () => {
|
|||||||
item.UserData
|
item.UserData
|
||||||
.PlayedPercentage
|
.PlayedPercentage
|
||||||
}
|
}
|
||||||
cardOrientation="landscape"
|
cardOrientation="sqaure"
|
||||||
></Card>
|
></Card>
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
|
|||||||
+43
-67
@@ -1,7 +1,6 @@
|
|||||||
/** @format */
|
/** @format */
|
||||||
|
|
||||||
import { useState, useEffect, useMemo } from "react";
|
import { useState, useEffect, useMemo } from "react";
|
||||||
import { Cookies, useCookies } from "react-cookie";
|
|
||||||
import { useQuery } from "@tanstack/react-query";
|
import { useQuery } from "@tanstack/react-query";
|
||||||
import { useNavigate, useParams, Link } from "react-router-dom";
|
import { useNavigate, useParams, Link } from "react-router-dom";
|
||||||
import { EventEmitter as event } from "../../eventEmitter.js";
|
import { EventEmitter as event } from "../../eventEmitter.js";
|
||||||
@@ -30,6 +29,8 @@ import FormControlLabel from "@mui/material/FormControlLabel";
|
|||||||
import Checkbox from "@mui/material/Checkbox";
|
import Checkbox from "@mui/material/Checkbox";
|
||||||
|
|
||||||
import { AvatarCard, AvatarImage } from "../../components/avatar/avatar.jsx";
|
import { AvatarCard, AvatarImage } from "../../components/avatar/avatar.jsx";
|
||||||
|
import { CardScroller } from "../../components/cardScroller/cardScroller.jsx";
|
||||||
|
import { Card } from "../../components/card/card.jsx";
|
||||||
import { AppBarBackOnly } from "../../components/appBar/backOnly.jsx";
|
import { AppBarBackOnly } from "../../components/appBar/backOnly.jsx";
|
||||||
|
|
||||||
// import { jellyfin } from "../../jellyfin";
|
// import { jellyfin } from "../../jellyfin";
|
||||||
@@ -38,6 +39,7 @@ import { getUserApi } from "@jellyfin/sdk/lib/utils/api/user-api";
|
|||||||
import { getBrandingApi } from "@jellyfin/sdk/lib/utils/api/branding-api";
|
import { getBrandingApi } from "@jellyfin/sdk/lib/utils/api/branding-api";
|
||||||
|
|
||||||
import "./login.module.scss";
|
import "./login.module.scss";
|
||||||
|
import { CardsSkeleton } from "../../components/skeleton/cards.jsx";
|
||||||
|
|
||||||
export const LoginWithImage = () => {
|
export const LoginWithImage = () => {
|
||||||
const { userName, userId } = useParams();
|
const { userName, userId } = useParams();
|
||||||
@@ -88,7 +90,6 @@ export const LoginWithImage = () => {
|
|||||||
saveUser(userName, password.password);
|
saveUser(userName, password.password);
|
||||||
}
|
}
|
||||||
event.emit("set-api-accessToken", window.api.basePath);
|
event.emit("set-api-accessToken", window.api.basePath);
|
||||||
// setAccessToken(user.data.AccessToken)
|
|
||||||
setLoading(false);
|
setLoading(false);
|
||||||
navigate(`/home`);
|
navigate(`/home`);
|
||||||
};
|
};
|
||||||
@@ -217,68 +218,52 @@ export const UserLogin = () => {
|
|||||||
const handleManualLogin = () => {
|
const handleManualLogin = () => {
|
||||||
navigate("/login/manual");
|
navigate("/login/manual");
|
||||||
};
|
};
|
||||||
const getUsers = async () => {
|
const users = useQuery({
|
||||||
const users = await getUserApi(window.api).getPublicUsers();
|
queryKey: ["login", "users"],
|
||||||
// console.log(users.data);
|
queryFn: async () => {
|
||||||
return users;
|
const users = await getUserApi(window.api).getPublicUsers();
|
||||||
// return {};
|
// console.log(users.data);
|
||||||
};
|
return users.data;
|
||||||
|
// return {};
|
||||||
const createApi = async () => {
|
},
|
||||||
const server = await getServer();
|
});
|
||||||
event.emit("create-jellyfin-api", server.Ip);
|
|
||||||
};
|
|
||||||
|
|
||||||
useMemo(() => {
|
|
||||||
// TODO Implement a better way to check and create api object when page reloaded. Hint: Maybe use session api or something (*route - login*)
|
|
||||||
if (!window.api) {
|
|
||||||
createApi().then(() => {
|
|
||||||
getUsers().then((users) => {
|
|
||||||
setUsers(users.data);
|
|
||||||
console.log(userList);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
} else {
|
|
||||||
getUsers().then((users) => {
|
|
||||||
setUsers(users.data);
|
|
||||||
console.log(userList);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}, []);
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<AppBarBackOnly />
|
<AppBarBackOnly />
|
||||||
<Container maxWidth="md" className="centered">
|
<Container maxWidth="md" className="centered">
|
||||||
<Typography variant="h3" sx={{ marginBottom: "1em" }}>
|
{/* <Typography variant="h3" sx={{ marginBottom: "1em" }}>
|
||||||
Users
|
Users
|
||||||
</Typography>
|
</Typography> */}
|
||||||
<div className="userList">
|
{users.isLoading ? (
|
||||||
{userList.map((item, index) => {
|
<CardsSkeleton />
|
||||||
return (
|
) : (
|
||||||
//
|
<CardScroller displayCards={5} title="Users">
|
||||||
<Link
|
{users.data.map((item, index) => {
|
||||||
to={`/login/withImg/${item.Name}/${item.Id}/`}
|
return (
|
||||||
key={item.Id}
|
//
|
||||||
className="userCard"
|
<Link
|
||||||
index={index}
|
to={`/login/withImg/${item.Name}/${item.Id}/`}
|
||||||
>
|
key={item.Id}
|
||||||
{item.PrimaryImageTag ? (
|
className="userCard"
|
||||||
<AvatarCard
|
index={index}
|
||||||
userName={item.Name}
|
>
|
||||||
userId={item.Id}
|
<Card
|
||||||
userImageAvailable={true}
|
key={index}
|
||||||
></AvatarCard>
|
itemName={item.Name}
|
||||||
) : (
|
itemId={item.Id}
|
||||||
<AvatarCard
|
imageTags={
|
||||||
userName={item.Name}
|
!!item.PrimaryImageTag
|
||||||
userImageAvailable={false}
|
}
|
||||||
></AvatarCard>
|
// cardType="sqaure"
|
||||||
)}
|
iconType="Person"
|
||||||
</Link>
|
cardOrientation="sqaure"
|
||||||
);
|
/>
|
||||||
})}
|
</Link>
|
||||||
</div>
|
);
|
||||||
|
})}
|
||||||
|
</CardScroller>
|
||||||
|
)}
|
||||||
<div className="buttons">
|
<div className="buttons">
|
||||||
<Button
|
<Button
|
||||||
color="secondary"
|
color="secondary"
|
||||||
@@ -375,15 +360,6 @@ export const UserLoginManual = () => {
|
|||||||
setRememberMe(event.target.checked);
|
setRememberMe(event.target.checked);
|
||||||
};
|
};
|
||||||
|
|
||||||
const createApi = async () => {
|
|
||||||
const server = await getServer();
|
|
||||||
event.emit("create-jellyfin-api", server.Ip);
|
|
||||||
};
|
|
||||||
|
|
||||||
if (!window.api) {
|
|
||||||
createApi();
|
|
||||||
}
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<AppBarBackOnly />
|
<AppBarBackOnly />
|
||||||
|
|||||||
@@ -2,11 +2,9 @@
|
|||||||
|
|
||||||
import { configureStore } from "@reduxjs/toolkit";
|
import { configureStore } from "@reduxjs/toolkit";
|
||||||
import sideBarReducer from "./utils/slice/sidemenu";
|
import sideBarReducer from "./utils/slice/sidemenu";
|
||||||
import homePageReducer from "./utils/slice/homePage";
|
|
||||||
|
|
||||||
export default configureStore({
|
export default configureStore({
|
||||||
reducer: {
|
reducer: {
|
||||||
sidebar: sideBarReducer,
|
sidebar: sideBarReducer,
|
||||||
homePage: homePageReducer,
|
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
@@ -1,63 +0,0 @@
|
|||||||
/** @format */
|
|
||||||
|
|
||||||
import { createSlice } from "@reduxjs/toolkit";
|
|
||||||
|
|
||||||
export const homePageSlice = createSlice({
|
|
||||||
name: "homePage",
|
|
||||||
initialState: [
|
|
||||||
{
|
|
||||||
type: "libs",
|
|
||||||
name: "Libraries",
|
|
||||||
data: [],
|
|
||||||
// isLoading: libraries.isLoading,
|
|
||||||
isLoading: false,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
type: "resumeVideo",
|
|
||||||
name: "Continue Watching",
|
|
||||||
data: [],
|
|
||||||
// isLoading: resumeItemsVideo.isLoading,
|
|
||||||
isLoading: false,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
type: "resumeAudio",
|
|
||||||
name: "Continue Listnening",
|
|
||||||
data: [],
|
|
||||||
// isLoading: resumeItemsAudio.isLoading,
|
|
||||||
isLoading: false,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
type: "nextup",
|
|
||||||
name: "Next Up",
|
|
||||||
data: [],
|
|
||||||
// isLoading: upNextItems.isLoading,
|
|
||||||
isLoading: false,
|
|
||||||
},
|
|
||||||
],
|
|
||||||
reducers: {
|
|
||||||
setData: (state, action) => {
|
|
||||||
switch (action.payload[0]) {
|
|
||||||
case "libs":
|
|
||||||
state[0].data = action.payload[1];
|
|
||||||
break;
|
|
||||||
case "resumeVideo":
|
|
||||||
state[1].data = action.payload[1];
|
|
||||||
break;
|
|
||||||
case "resumeAudio":
|
|
||||||
state[2].data = action.payload[1];
|
|
||||||
break;
|
|
||||||
case "nextup":
|
|
||||||
state[3].data = action.payload[1];
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
},
|
|
||||||
addLatestMedia: (state, action) => {
|
|
||||||
state.push(action.payload);
|
|
||||||
},
|
|
||||||
},
|
|
||||||
});
|
|
||||||
|
|
||||||
export const { setData, addLatestMedia } = homePageSlice.actions;
|
|
||||||
export default homePageSlice.reducer;
|
|
||||||
Reference in new issue
Block a user