feat: add new server page
This commit is contained in:
13 files changed
+506
-69
No files matched your search
@@ -203,30 +203,23 @@ export const AppBar = () => {
|
||||
<Divider variant="middle" />
|
||||
<List>
|
||||
<ListItem>
|
||||
<ListItemButton
|
||||
onClick={() => {
|
||||
setSettingsDialogOpen(true);
|
||||
setSettingsTabValue(1);
|
||||
}}
|
||||
<ListItemLink
|
||||
to="/settings"
|
||||
icon="settings"
|
||||
primary="Settings"
|
||||
style={{
|
||||
borderRadius: "100px",
|
||||
gap: "0.85em",
|
||||
}}
|
||||
>
|
||||
<span className="material-symbols-rounded">settings</span>
|
||||
Settings
|
||||
</ListItemButton>
|
||||
/>
|
||||
</ListItem>
|
||||
<ListItem>
|
||||
<ListItemButton
|
||||
onClick={() => {
|
||||
setSettingsDialogOpen(true);
|
||||
setSettingsTabValue(2);
|
||||
}}
|
||||
style={{
|
||||
borderRadius: "100px",
|
||||
gap: "0.85em",
|
||||
}}
|
||||
disabled
|
||||
>
|
||||
<span className="material-symbols-rounded">dns</span>
|
||||
Change Server
|
||||
|
||||
@@ -89,6 +89,15 @@
|
||||
border-radius: 8px;
|
||||
object-fit: cover;
|
||||
box-shadow: 0 2px 8px rgba(0,0,0,0.2);
|
||||
|
||||
&.placeholder {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
background: rgb(100 100 100 / 0.1);
|
||||
color: rgb(200 200 200 / 0.7);
|
||||
font-size: 2rem;
|
||||
}
|
||||
}
|
||||
|
||||
& > div {
|
||||
|
||||
@@ -113,14 +113,16 @@ const Carousel = ({
|
||||
>
|
||||
<CarouselTickers
|
||||
imageUrl={
|
||||
getImageUrlsApi(api).getItemImageUrlById(
|
||||
item.Id ?? "",
|
||||
"Thumb",
|
||||
{
|
||||
quality: 90,
|
||||
fillHeight: 360,
|
||||
},
|
||||
) ?? undefined
|
||||
item.ImageTags?.Thumb
|
||||
? getImageUrlsApi(api).getItemImageUrlById(
|
||||
item.Id ?? "",
|
||||
"Thumb",
|
||||
{
|
||||
quality: 90,
|
||||
fillHeight: 360,
|
||||
},
|
||||
)
|
||||
: undefined
|
||||
}
|
||||
isActive={index === currentSlide}
|
||||
itemName={item.Name ?? "Unknown"}
|
||||
@@ -131,6 +133,7 @@ const Carousel = ({
|
||||
}
|
||||
onTickerClick={handleTickerClick}
|
||||
index={index}
|
||||
itemType={item.Type as BaseItemKind}
|
||||
/>
|
||||
</div>
|
||||
))}
|
||||
|
||||
@@ -1,13 +1,16 @@
|
||||
import type { BaseItemKind } from "@jellyfin/sdk/lib/generated-client";
|
||||
import { Typography } from "@mui/material";
|
||||
import React from "react";
|
||||
import { getTypeIcon } from "../utils/iconsCollection";
|
||||
|
||||
type CarouselTickersProps = {
|
||||
imageUrl?: string;
|
||||
imageUrl?: string | undefined | null;
|
||||
itemName: string;
|
||||
itemYear: string;
|
||||
onTickerClick: (index: number) => void;
|
||||
index: number;
|
||||
isActive: boolean;
|
||||
itemType: BaseItemKind;
|
||||
};
|
||||
|
||||
const CarouselTickers = React.memo(
|
||||
@@ -18,6 +21,7 @@ const CarouselTickers = React.memo(
|
||||
onTickerClick,
|
||||
index,
|
||||
isActive,
|
||||
itemType,
|
||||
}: CarouselTickersProps) => {
|
||||
const handleClick = React.useCallback(() => {
|
||||
onTickerClick(index);
|
||||
@@ -28,12 +32,18 @@ const CarouselTickers = React.memo(
|
||||
className={`carousel-ticker${isActive ? " active" : ""}`}
|
||||
onClick={handleClick}
|
||||
>
|
||||
<img
|
||||
src={imageUrl}
|
||||
alt={itemName}
|
||||
className="carousel-ticker-image"
|
||||
// style={{ width: "5em", height: "100%", objectFit: "cover" }}
|
||||
/>
|
||||
{imageUrl ? (
|
||||
<img
|
||||
src={imageUrl}
|
||||
alt={itemName}
|
||||
className="carousel-ticker-image"
|
||||
/>
|
||||
) : (
|
||||
<div className="carousel-ticker-image placeholder material-symbols-rounded">
|
||||
{" "}
|
||||
{getTypeIcon(itemType)}
|
||||
</div>
|
||||
)}
|
||||
<div>
|
||||
<Typography variant="subtitle1" className="carousel-ticker-title">
|
||||
{itemName}
|
||||
|
||||
@@ -17,10 +17,6 @@ import React, {
|
||||
import { delUser } from "@/utils/storage/user";
|
||||
import { useApiInContext } from "@/utils/store/api";
|
||||
import { useCentralStore } from "@/utils/store/central";
|
||||
import {
|
||||
setSettingsDialogOpen,
|
||||
setSettingsTabValue,
|
||||
} from "@/utils/store/settings";
|
||||
|
||||
export const UserAvatarMenu = () => {
|
||||
const api = useApiInContext((s) => s.api);
|
||||
@@ -105,18 +101,6 @@ export const UserAvatarMenu = () => {
|
||||
Logout
|
||||
</MenuItem>
|
||||
<Divider />
|
||||
<MenuItem
|
||||
onClick={() => {
|
||||
setSettingsDialogOpen(true);
|
||||
setSettingsTabValue(1);
|
||||
handleMenuClose();
|
||||
}}
|
||||
>
|
||||
<ListItemIcon>
|
||||
<span className="material-symbols-rounded">settings</span>
|
||||
</ListItemIcon>
|
||||
Settings
|
||||
</MenuItem>
|
||||
<MenuItem
|
||||
onClick={() => {
|
||||
navigate({ to: "/settings/preferences" });
|
||||
|
||||
@@ -36,6 +36,7 @@ import { Route as ApiEpisodeIdRouteImport } from './routes/_api/episode/$id'
|
||||
import { Route as ApiBoxsetIdRouteImport } from './routes/_api/boxset/$id'
|
||||
import { Route as ApiArtistIdRouteImport } from './routes/_api/artist/$id'
|
||||
import { Route as ApiAlbumIdRouteImport } from './routes/_api/album/$id'
|
||||
import { Route as ApiSettingsChangeServerIndexRouteImport } from './routes/_api/settings/changeServer/index'
|
||||
import { Route as ApiLoginUserIdUserNameRouteImport } from './routes/_api/login/$userId.$userName'
|
||||
|
||||
const ApiRoute = ApiRouteImport.update({
|
||||
@@ -172,6 +173,12 @@ const ApiAlbumIdRoute = ApiAlbumIdRouteImport.update({
|
||||
path: '/album/$id',
|
||||
getParentRoute: () => ApiRoute,
|
||||
} as any)
|
||||
const ApiSettingsChangeServerIndexRoute =
|
||||
ApiSettingsChangeServerIndexRouteImport.update({
|
||||
id: '/changeServer/',
|
||||
path: '/changeServer/',
|
||||
getParentRoute: () => ApiSettingsRoute,
|
||||
} as any)
|
||||
const ApiLoginUserIdUserNameRoute = ApiLoginUserIdUserNameRouteImport.update({
|
||||
id: '/$userId/$userName',
|
||||
path: '/$userId/$userName',
|
||||
@@ -206,6 +213,7 @@ export interface FileRoutesByFullPath {
|
||||
'/player/': typeof ApiPlayerIndexRoute
|
||||
'/search/': typeof ApiSearchIndexRoute
|
||||
'/login/$userId/$userName': typeof ApiLoginUserIdUserNameRoute
|
||||
'/settings/changeServer/': typeof ApiSettingsChangeServerIndexRoute
|
||||
}
|
||||
export interface FileRoutesByTo {
|
||||
'/': typeof IndexRoute
|
||||
@@ -235,6 +243,7 @@ export interface FileRoutesByTo {
|
||||
'/player': typeof ApiPlayerIndexRoute
|
||||
'/search': typeof ApiSearchIndexRoute
|
||||
'/login/$userId/$userName': typeof ApiLoginUserIdUserNameRoute
|
||||
'/settings/changeServer': typeof ApiSettingsChangeServerIndexRoute
|
||||
}
|
||||
export interface FileRoutesById {
|
||||
__root__: typeof rootRouteImport
|
||||
@@ -266,6 +275,7 @@ export interface FileRoutesById {
|
||||
'/_api/player/': typeof ApiPlayerIndexRoute
|
||||
'/_api/search/': typeof ApiSearchIndexRoute
|
||||
'/_api/login/$userId/$userName': typeof ApiLoginUserIdUserNameRoute
|
||||
'/_api/settings/changeServer/': typeof ApiSettingsChangeServerIndexRoute
|
||||
}
|
||||
export interface FileRouteTypes {
|
||||
fileRoutesByFullPath: FileRoutesByFullPath
|
||||
@@ -297,6 +307,7 @@ export interface FileRouteTypes {
|
||||
| '/player/'
|
||||
| '/search/'
|
||||
| '/login/$userId/$userName'
|
||||
| '/settings/changeServer/'
|
||||
fileRoutesByTo: FileRoutesByTo
|
||||
to:
|
||||
| '/'
|
||||
@@ -326,6 +337,7 @@ export interface FileRouteTypes {
|
||||
| '/player'
|
||||
| '/search'
|
||||
| '/login/$userId/$userName'
|
||||
| '/settings/changeServer'
|
||||
id:
|
||||
| '__root__'
|
||||
| '/'
|
||||
@@ -356,6 +368,7 @@ export interface FileRouteTypes {
|
||||
| '/_api/player/'
|
||||
| '/_api/search/'
|
||||
| '/_api/login/$userId/$userName'
|
||||
| '/_api/settings/changeServer/'
|
||||
fileRoutesById: FileRoutesById
|
||||
}
|
||||
export interface RootRouteChildren {
|
||||
@@ -558,6 +571,13 @@ declare module '@tanstack/react-router' {
|
||||
preLoaderRoute: typeof ApiAlbumIdRouteImport
|
||||
parentRoute: typeof ApiRoute
|
||||
}
|
||||
'/_api/settings/changeServer/': {
|
||||
id: '/_api/settings/changeServer/'
|
||||
path: '/changeServer'
|
||||
fullPath: '/settings/changeServer/'
|
||||
preLoaderRoute: typeof ApiSettingsChangeServerIndexRouteImport
|
||||
parentRoute: typeof ApiSettingsRoute
|
||||
}
|
||||
'/_api/login/$userId/$userName': {
|
||||
id: '/_api/login/$userId/$userName'
|
||||
path: '/$userId/$userName'
|
||||
@@ -587,11 +607,13 @@ const ApiLoginRouteWithChildren = ApiLoginRoute._addFileChildren(
|
||||
interface ApiSettingsRouteChildren {
|
||||
ApiSettingsAboutRoute: typeof ApiSettingsAboutRoute
|
||||
ApiSettingsPreferencesRoute: typeof ApiSettingsPreferencesRoute
|
||||
ApiSettingsChangeServerIndexRoute: typeof ApiSettingsChangeServerIndexRoute
|
||||
}
|
||||
|
||||
const ApiSettingsRouteChildren: ApiSettingsRouteChildren = {
|
||||
ApiSettingsAboutRoute: ApiSettingsAboutRoute,
|
||||
ApiSettingsPreferencesRoute: ApiSettingsPreferencesRoute,
|
||||
ApiSettingsChangeServerIndexRoute: ApiSettingsChangeServerIndexRoute,
|
||||
}
|
||||
|
||||
const ApiSettingsRouteWithChildren = ApiSettingsRoute._addFileChildren(
|
||||
|
||||
@@ -3,10 +3,12 @@ import React, { useCallback, useMemo } from "react";
|
||||
|
||||
import "./home.scss";
|
||||
|
||||
import type { Api } from "@jellyfin/sdk";
|
||||
import {
|
||||
type BaseItemDto,
|
||||
BaseItemKind,
|
||||
ItemFields,
|
||||
type UserDto,
|
||||
} from "@jellyfin/sdk/lib/generated-client";
|
||||
import { getItemsApi } from "@jellyfin/sdk/lib/utils/api/items-api";
|
||||
import { getTvShowsApi } from "@jellyfin/sdk/lib/utils/api/tv-shows-api";
|
||||
@@ -40,10 +42,17 @@ function Home() {
|
||||
const api = useApiInContext((s) => s.api);
|
||||
const user = useCentralStore((s) => s.currentUser);
|
||||
|
||||
if (!api || !user?.Id) {
|
||||
return <CircularPageLoadingAnimation />;
|
||||
}
|
||||
|
||||
return <HomeContent api={api} user={user} />;
|
||||
}
|
||||
|
||||
function HomeContent({ api, user }: { api: Api; user: UserDto }) {
|
||||
const libraries = useSuspenseQuery({
|
||||
queryKey: ["libraries"],
|
||||
queryFn: async () => {
|
||||
if (!api || !user?.Id) return null;
|
||||
const libs = await getUserViewsApi(api).getUserViews({
|
||||
userId: user.Id,
|
||||
});
|
||||
@@ -52,12 +61,13 @@ function Home() {
|
||||
networkMode: "always",
|
||||
});
|
||||
|
||||
const latestMedia = useSuspenseQuery(getLatestItemsQueryOptions(api, user?.Id));
|
||||
const latestMedia = useSuspenseQuery(
|
||||
getLatestItemsQueryOptions(api, user.Id),
|
||||
);
|
||||
|
||||
const resumeItemsVideo = useSuspenseQuery({
|
||||
queryKey: ["home", "resume", "video"],
|
||||
queryFn: async () => {
|
||||
if (!api || !user?.Id) return null;
|
||||
const resumeItems = await getItemsApi(api).getResumeItems({
|
||||
userId: user.Id,
|
||||
limit: 10,
|
||||
@@ -72,9 +82,8 @@ function Home() {
|
||||
const resumeItemsAudio = useSuspenseQuery({
|
||||
queryKey: ["home", "resume", "audio"],
|
||||
queryFn: async () => {
|
||||
if (!api || !user?.Id) return null;
|
||||
const resumeItems = await getItemsApi(api).getResumeItems({
|
||||
userId: user?.Id,
|
||||
userId: user.Id,
|
||||
limit: 10,
|
||||
mediaTypes: ["Audio"],
|
||||
enableUserData: true,
|
||||
@@ -87,9 +96,8 @@ function Home() {
|
||||
const upNextItems = useSuspenseQuery({
|
||||
queryKey: ["home", "upNext"],
|
||||
queryFn: async () => {
|
||||
if (!api || !user?.Id) return null;
|
||||
const upNext = await getTvShowsApi(api).getNextUp({
|
||||
userId: user?.Id,
|
||||
userId: user.Id,
|
||||
fields: [
|
||||
ItemFields.PrimaryImageAspectRatio,
|
||||
ItemFields.MediaStreams,
|
||||
|
||||
@@ -12,9 +12,6 @@ import { useSnackbar } from "notistack";
|
||||
import { AvatarImage } from "@/components/avatar/avatar.jsx";
|
||||
import "./login.scss";
|
||||
|
||||
import { saveUser } from "@/utils/storage/user";
|
||||
import { useApiInContext } from "@/utils/store/api";
|
||||
import { useBackdropStore } from "@/utils/store/backdrop.js";
|
||||
import { useMutation } from "@tanstack/react-query";
|
||||
import {
|
||||
createFileRoute,
|
||||
@@ -27,6 +24,9 @@ import React, {
|
||||
useEffect,
|
||||
useState,
|
||||
} from "react";
|
||||
import { saveUser } from "@/utils/storage/user";
|
||||
import { useApiInContext } from "@/utils/store/api";
|
||||
import { useBackdropStore } from "@/utils/store/backdrop.js";
|
||||
|
||||
export const Route = createFileRoute("/_api/login/$userId/$userName")({
|
||||
component: LoginUser,
|
||||
@@ -102,7 +102,13 @@ function LoginUser() {
|
||||
}
|
||||
createApi(api.basePath, authenticate.data?.AccessToken);
|
||||
|
||||
if (rememberMe) await saveUser(userName, authenticate.data.AccessToken);
|
||||
if (authenticate.data.SessionInfo?.UserId && rememberMe) {
|
||||
await saveUser(
|
||||
userName,
|
||||
authenticate.data.AccessToken,
|
||||
authenticate.data.SessionInfo.UserId,
|
||||
);
|
||||
}
|
||||
|
||||
router.invalidate().finally(() => {
|
||||
navigate({ to: "/home", replace: true });
|
||||
|
||||
@@ -63,6 +63,12 @@ function SettingsRoute() {
|
||||
primary="Preferences"
|
||||
className="settings-sidebar-list-item"
|
||||
/>
|
||||
<ListItemLink
|
||||
to="/settings/changeServer"
|
||||
icon="dns"
|
||||
primary="Servers"
|
||||
className="settings-sidebar-list-item"
|
||||
/>
|
||||
<ListItemLink
|
||||
to="/settings/about"
|
||||
icon="info"
|
||||
|
||||
@@ -0,0 +1,379 @@
|
||||
import {
|
||||
alpha,
|
||||
Button,
|
||||
Card,
|
||||
CardActions,
|
||||
CardContent,
|
||||
Chip,
|
||||
Grid,
|
||||
IconButton,
|
||||
Typography,
|
||||
useTheme,
|
||||
} from "@mui/material";
|
||||
import { useQuery, useQueryClient } from "@tanstack/react-query";
|
||||
import { createFileRoute } from "@tanstack/react-router";
|
||||
import { useSnackbar } from "notistack";
|
||||
import React, { useState } from "react";
|
||||
import AddServerDialog from "@/components/addServerDialog";
|
||||
import CircularPageLoadingAnimation from "@/components/circularPageLoadingAnimation";
|
||||
import {
|
||||
delServer,
|
||||
getAllServers,
|
||||
getDefaultServer,
|
||||
setDefaultServer,
|
||||
} from "@/utils/storage/servers";
|
||||
import { delUser } from "@/utils/storage/user";
|
||||
import { useApiInContext } from "@/utils/store/api";
|
||||
|
||||
export const Route = createFileRoute("/_api/settings/changeServer/")({
|
||||
component: ChangeServerRoute,
|
||||
});
|
||||
|
||||
function ChangeServerRoute() {
|
||||
const _theme = useTheme();
|
||||
const queryClient = useQueryClient();
|
||||
const createApi = useApiInContext((s) => s.createApi);
|
||||
const { enqueueSnackbar } = useSnackbar();
|
||||
const [addServerDialogOpen, setAddServerDialogOpen] = useState(false);
|
||||
|
||||
const serversQuery = useQuery({
|
||||
queryKey: ["servers"],
|
||||
queryFn: async () => {
|
||||
return await getAllServers();
|
||||
},
|
||||
});
|
||||
|
||||
const activeServerQuery = useQuery({
|
||||
queryKey: ["activeServer"],
|
||||
queryFn: async () => {
|
||||
return await getDefaultServer();
|
||||
},
|
||||
});
|
||||
|
||||
const handleConnect = async (serverId: string) => {
|
||||
try {
|
||||
// Clear current user when switching servers to force login/user fetch
|
||||
await delUser();
|
||||
await setDefaultServer(serverId);
|
||||
|
||||
const servers = await getAllServers();
|
||||
const server = servers.find((s) => s.id === serverId);
|
||||
|
||||
if (server) {
|
||||
createApi(server.address);
|
||||
}
|
||||
|
||||
// Reload the page to reset API context and states
|
||||
window.location.href = "/";
|
||||
} catch (error) {
|
||||
console.error("Failed to switch server", error);
|
||||
enqueueSnackbar("Failed to switch server", { variant: "error" });
|
||||
}
|
||||
};
|
||||
|
||||
const handleDelete = async (serverId: string) => {
|
||||
try {
|
||||
await delServer(serverId);
|
||||
queryClient.invalidateQueries({ queryKey: ["servers"] });
|
||||
enqueueSnackbar("Server removed", { variant: "success" });
|
||||
} catch (error) {
|
||||
console.error("Failed to delete server", error);
|
||||
enqueueSnackbar("Failed to delete server", { variant: "error" });
|
||||
}
|
||||
};
|
||||
|
||||
if (serversQuery.isLoading || activeServerQuery.isLoading) {
|
||||
return <CircularPageLoadingAnimation />;
|
||||
}
|
||||
|
||||
return (
|
||||
<div className="settings-page-scrollY">
|
||||
<div
|
||||
style={{
|
||||
marginBottom: "2em",
|
||||
}}
|
||||
>
|
||||
<Typography variant="h4">Servers</Typography>
|
||||
</div>
|
||||
|
||||
<Grid container spacing={3}>
|
||||
{serversQuery.data?.map((server) => {
|
||||
const isActive = activeServerQuery.data === server.id;
|
||||
const spalshUrl =
|
||||
new URL(server.address).pathname.length > 1
|
||||
? `${new URL(server.address).origin}${`${new URL(server.address).pathname}/`}Branding/Splashscreen?fillWidth=400&fillHeight=100`
|
||||
: `${server.address}Branding/Splashscreen?fillWidth=400&fillHeight=100`;
|
||||
|
||||
return (
|
||||
<Grid size={{ xs: 12, sm: 12, md: 6, lg: 4 }} key={server.id}>
|
||||
<Card
|
||||
elevation={0}
|
||||
sx={{
|
||||
height: "100%",
|
||||
minHeight: "280px",
|
||||
display: "flex",
|
||||
flexDirection: "column",
|
||||
position: "relative",
|
||||
overflow: "hidden",
|
||||
borderRadius: "24px",
|
||||
transition: "all 0.3s cubic-bezier(0.4, 0, 0.2, 1)",
|
||||
border: "1px solid rgba(255, 255, 255, 0.08)",
|
||||
background: "rgba(30, 30, 35, 0.4)",
|
||||
boxShadow: "none",
|
||||
backdropFilter: "blur(12px)",
|
||||
"&:hover": {
|
||||
transform: "translateY(-4px)",
|
||||
boxShadow: "0 12px 40px rgba(0,0,0,0.3)",
|
||||
borderColor: "rgba(255, 255, 255, 0.2)",
|
||||
"& .server-card-bg": {
|
||||
transform: "scale(1.05)",
|
||||
},
|
||||
},
|
||||
}}
|
||||
>
|
||||
{/* Standard BG Section / Cover Area */}
|
||||
<div
|
||||
className="server-card-bg"
|
||||
style={{
|
||||
height: "100px",
|
||||
width: "100%",
|
||||
background: "linear-gradient(45deg, #2a2a35, #1a1a20)",
|
||||
position: "absolute",
|
||||
top: 0,
|
||||
left: 0,
|
||||
zIndex: 0,
|
||||
transition: "transform 0.4s ease",
|
||||
}}
|
||||
>
|
||||
<img
|
||||
alt={server.systemInfo?.ServerName || "Unknown Server"}
|
||||
src={spalshUrl}
|
||||
style={{
|
||||
height: "100%",
|
||||
width: "100%",
|
||||
objectFit: "cover",
|
||||
}}
|
||||
/>
|
||||
</div>
|
||||
|
||||
{isActive && (
|
||||
<Chip
|
||||
label="Active"
|
||||
size="small"
|
||||
color="primary"
|
||||
sx={{
|
||||
fontWeight: "bold",
|
||||
position: "absolute",
|
||||
top: 24,
|
||||
right: 24,
|
||||
zIndex: 2,
|
||||
}}
|
||||
/>
|
||||
)}
|
||||
|
||||
<CardContent
|
||||
sx={{
|
||||
flexGrow: 1,
|
||||
zIndex: 1,
|
||||
pt: "60px !important", // Push content down to overlap properly
|
||||
px: 3,
|
||||
}}
|
||||
>
|
||||
<div
|
||||
style={{
|
||||
display: "flex",
|
||||
justifyContent: "space-between",
|
||||
alignItems: "flex-end",
|
||||
marginBottom: "1.5rem",
|
||||
}}
|
||||
>
|
||||
<div
|
||||
style={{
|
||||
width: "64px",
|
||||
height: "64px",
|
||||
borderRadius: "20px",
|
||||
background: "rgba(30, 30, 40, 0.8)",
|
||||
backdropFilter: "blur(4px)",
|
||||
border: "1px solid rgba(255,255,255,0.1)",
|
||||
display: "flex",
|
||||
alignItems: "center",
|
||||
justifyContent: "center",
|
||||
boxShadow: "0 8px 16px rgba(0,0,0,0.2)",
|
||||
}}
|
||||
>
|
||||
<span
|
||||
className="material-symbols-rounded"
|
||||
style={{
|
||||
fontSize: "32px",
|
||||
color: "#fff",
|
||||
opacity: isActive ? 1 : 0.8,
|
||||
}}
|
||||
>
|
||||
dns
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<Typography
|
||||
variant="h5"
|
||||
component="div"
|
||||
fontWeight="bold"
|
||||
noWrap
|
||||
title={server.systemInfo?.ServerName || "Unknown Server"}
|
||||
sx={{ mb: 0.5, letterSpacing: "-0.02em" }}
|
||||
>
|
||||
{server.systemInfo?.ServerName || "Unknown Server"}
|
||||
</Typography>
|
||||
<Typography
|
||||
variant="body2"
|
||||
color="text.secondary"
|
||||
noWrap
|
||||
title={server.address}
|
||||
sx={{
|
||||
opacity: 0.6,
|
||||
fontFamily: "monospace",
|
||||
fontSize: "0.85rem",
|
||||
}}
|
||||
>
|
||||
{server.address}
|
||||
</Typography>
|
||||
</CardContent>
|
||||
|
||||
<CardActions
|
||||
sx={{
|
||||
justifyContent: "space-between",
|
||||
padding: "24px",
|
||||
zIndex: 1,
|
||||
mt: "auto",
|
||||
}}
|
||||
>
|
||||
<Button
|
||||
variant="outlined"
|
||||
color="error"
|
||||
size="small"
|
||||
onClick={() => handleDelete(server.id)}
|
||||
sx={{
|
||||
minWidth: "40px",
|
||||
width: "40px",
|
||||
height: "40px",
|
||||
borderRadius: "12px",
|
||||
p: 0,
|
||||
border: "1px solid rgba(211, 47, 47, 0.3)",
|
||||
"&:hover": {
|
||||
backgroundColor: "rgba(211, 47, 47, 0.1)",
|
||||
border: "1px solid rgba(211, 47, 47, 0.8)",
|
||||
},
|
||||
}}
|
||||
>
|
||||
<span className="material-symbols-rounded">delete</span>
|
||||
</Button>
|
||||
|
||||
{!isActive ? (
|
||||
<Button
|
||||
variant="contained"
|
||||
onClick={() => handleConnect(server.id)}
|
||||
sx={{
|
||||
borderRadius: "12px",
|
||||
textTransform: "none",
|
||||
fontWeight: 600,
|
||||
px: 3,
|
||||
}}
|
||||
>
|
||||
Connect
|
||||
</Button>
|
||||
) : (
|
||||
<Button
|
||||
disabled
|
||||
startIcon={
|
||||
<span className="material-symbols-rounded">check</span>
|
||||
}
|
||||
sx={{
|
||||
borderRadius: "12px",
|
||||
textTransform: "none",
|
||||
fontWeight: 600,
|
||||
color: "text.primary",
|
||||
"&.Mui-disabled": {
|
||||
color: "text.primary",
|
||||
opacity: 0.7,
|
||||
},
|
||||
}}
|
||||
>
|
||||
Connected
|
||||
</Button>
|
||||
)}
|
||||
</CardActions>
|
||||
</Card>
|
||||
</Grid>
|
||||
);
|
||||
})}
|
||||
|
||||
{/* Add Server Card */}
|
||||
<Grid size={{ xs: 12, sm: 12, md: 6, lg: 4 }}>
|
||||
<Card
|
||||
onClick={() => setAddServerDialogOpen(true)}
|
||||
elevation={0}
|
||||
sx={{
|
||||
height: "100%",
|
||||
minHeight: "280px",
|
||||
display: "flex",
|
||||
flexDirection: "column",
|
||||
alignItems: "center",
|
||||
justifyContent: "center",
|
||||
position: "relative",
|
||||
borderRadius: "24px",
|
||||
cursor: "pointer",
|
||||
background: "rgba(255, 255, 255, 0.02)",
|
||||
border: "2px dashed rgba(255, 255, 255, 0.1)",
|
||||
transition: "all 0.2s ease-in-out",
|
||||
"&:hover": {
|
||||
background: "rgba(255, 255, 255, 0.05)",
|
||||
borderColor: "rgba(255, 255, 255, 0.3)",
|
||||
transform: "translateY(-4px)",
|
||||
"& .add-icon": {
|
||||
transform: "scale(1.1) rotate(90deg)",
|
||||
color: "var(--mui-palette-primary-main)",
|
||||
},
|
||||
},
|
||||
}}
|
||||
>
|
||||
<div
|
||||
className="add-icon"
|
||||
style={{
|
||||
width: "80px",
|
||||
height: "80px",
|
||||
borderRadius: "50%",
|
||||
backgroundColor: "rgba(255, 255, 255, 0.05)",
|
||||
display: "flex",
|
||||
alignItems: "center",
|
||||
justifyContent: "center",
|
||||
marginBottom: "1.5rem",
|
||||
transition: "all 0.3s cubic-bezier(0.34, 1.56, 0.64, 1)",
|
||||
}}
|
||||
>
|
||||
<span
|
||||
className="material-symbols-rounded"
|
||||
style={{ fontSize: "40px", opacity: 0.7 }}
|
||||
>
|
||||
add
|
||||
</span>
|
||||
</div>
|
||||
<Typography variant="h6" fontWeight="bold">
|
||||
Add Server
|
||||
</Typography>
|
||||
<Typography variant="body2" color="text.secondary" sx={{ mt: 1 }}>
|
||||
Connect to a new Jellyfin server
|
||||
</Typography>
|
||||
</Card>
|
||||
</Grid>
|
||||
</Grid>
|
||||
|
||||
<AddServerDialog
|
||||
open={addServerDialogOpen}
|
||||
setAddServerDialog={setAddServerDialogOpen}
|
||||
sideEffect={async () => {
|
||||
await queryClient.invalidateQueries({ queryKey: ["servers"] });
|
||||
}}
|
||||
/>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
@@ -18,8 +18,11 @@ export const getItemQueryOptions = (
|
||||
queryOptions({
|
||||
queryKey: ["item", id],
|
||||
queryFn: async () => {
|
||||
if (!api || !userId) {
|
||||
throw Error("API or User ID is not defined");
|
||||
if (!api) {
|
||||
throw Error("API is not defined");
|
||||
}
|
||||
if (!userId) {
|
||||
throw Error("User ID is not defined");
|
||||
}
|
||||
const result = await getUserLibraryApi(api).getItem({
|
||||
userId: userId,
|
||||
@@ -42,8 +45,11 @@ export const getLatestItemsQueryOptions = (
|
||||
queryOptions({
|
||||
queryKey: ["home", "latestMedia"],
|
||||
queryFn: async () => {
|
||||
if (!api || !userId) {
|
||||
throw Error("API or User ID is not defined");
|
||||
if (!api) {
|
||||
throw Error("API is not defined");
|
||||
}
|
||||
if (!userId) {
|
||||
throw Error("User ID is not defined");
|
||||
}
|
||||
const media = await getUserLibraryApi(api).getLatestMedia({
|
||||
userId: userId,
|
||||
|
||||
@@ -1,21 +1,27 @@
|
||||
import { load } from "@tauri-apps/plugin-store";
|
||||
|
||||
export interface UserStore {
|
||||
user: {
|
||||
Name: string;
|
||||
AccessToken: string;
|
||||
};
|
||||
}
|
||||
user: {
|
||||
Name: string;
|
||||
AccessToken: string;
|
||||
Id: string;
|
||||
};
|
||||
}
|
||||
|
||||
const user = await load(".user.dat", { autoSave: true });
|
||||
|
||||
/**
|
||||
* Set User details to .user.dat
|
||||
*/
|
||||
const saveUser = async (userName: string, accessToken: string) => {
|
||||
const saveUser = async (
|
||||
userName: string,
|
||||
accessToken: string,
|
||||
userId: string,
|
||||
) => {
|
||||
user.set("user", {
|
||||
Name: userName,
|
||||
AccessToken: accessToken,
|
||||
Id: userId,
|
||||
});
|
||||
|
||||
await user.save();
|
||||
|
||||
@@ -1,17 +1,21 @@
|
||||
import type { Api } from "@jellyfin/sdk";
|
||||
import type { UserDto } from "@jellyfin/sdk/lib/generated-client";
|
||||
import { getUserApi } from "@jellyfin/sdk/lib/utils/api/user-api";
|
||||
import React, { type ReactNode } from "react";
|
||||
import { createContext, useContext, useState } from "react";
|
||||
import { type StoreApi, createStore } from "zustand";
|
||||
import React, {
|
||||
createContext,
|
||||
type ReactNode,
|
||||
useContext,
|
||||
useState,
|
||||
} from "react";
|
||||
import { createStore, type StoreApi } from "zustand";
|
||||
import { shallow } from "zustand/shallow";
|
||||
import { useStoreWithEqualityFn } from "zustand/traditional";
|
||||
import { version } from "../../../package.json";
|
||||
import {
|
||||
type ServerInfo,
|
||||
getAllServers,
|
||||
getDefaultServer,
|
||||
getServer,
|
||||
type ServerInfo,
|
||||
} from "../storage/servers";
|
||||
import { getUser } from "../storage/user";
|
||||
|
||||
@@ -22,6 +26,7 @@ type CentralStore = {
|
||||
userOnDisk: () => Promise<{
|
||||
Name: string;
|
||||
AccessToken: string;
|
||||
Id: string;
|
||||
} | null>;
|
||||
clientVersion: string;
|
||||
currentUser: null | UserDto;
|
||||
|
||||
Reference in new issue
Block a user