feat: add new server page
This commit is contained in:
13 files changed
+490
-53
No files matched your search
@@ -203,30 +203,23 @@ export const AppBar = () => {
|
|||||||
<Divider variant="middle" />
|
<Divider variant="middle" />
|
||||||
<List>
|
<List>
|
||||||
<ListItem>
|
<ListItem>
|
||||||
<ListItemButton
|
<ListItemLink
|
||||||
onClick={() => {
|
to="/settings"
|
||||||
setSettingsDialogOpen(true);
|
icon="settings"
|
||||||
setSettingsTabValue(1);
|
primary="Settings"
|
||||||
}}
|
|
||||||
style={{
|
style={{
|
||||||
borderRadius: "100px",
|
borderRadius: "100px",
|
||||||
gap: "0.85em",
|
gap: "0.85em",
|
||||||
}}
|
}}
|
||||||
>
|
/>
|
||||||
<span className="material-symbols-rounded">settings</span>
|
|
||||||
Settings
|
|
||||||
</ListItemButton>
|
|
||||||
</ListItem>
|
</ListItem>
|
||||||
<ListItem>
|
<ListItem>
|
||||||
<ListItemButton
|
<ListItemButton
|
||||||
onClick={() => {
|
|
||||||
setSettingsDialogOpen(true);
|
|
||||||
setSettingsTabValue(2);
|
|
||||||
}}
|
|
||||||
style={{
|
style={{
|
||||||
borderRadius: "100px",
|
borderRadius: "100px",
|
||||||
gap: "0.85em",
|
gap: "0.85em",
|
||||||
}}
|
}}
|
||||||
|
disabled
|
||||||
>
|
>
|
||||||
<span className="material-symbols-rounded">dns</span>
|
<span className="material-symbols-rounded">dns</span>
|
||||||
Change Server
|
Change Server
|
||||||
|
|||||||
@@ -89,6 +89,15 @@
|
|||||||
border-radius: 8px;
|
border-radius: 8px;
|
||||||
object-fit: cover;
|
object-fit: cover;
|
||||||
box-shadow: 0 2px 8px rgba(0,0,0,0.2);
|
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 {
|
& > div {
|
||||||
|
|||||||
@@ -113,14 +113,16 @@ const Carousel = ({
|
|||||||
>
|
>
|
||||||
<CarouselTickers
|
<CarouselTickers
|
||||||
imageUrl={
|
imageUrl={
|
||||||
getImageUrlsApi(api).getItemImageUrlById(
|
item.ImageTags?.Thumb
|
||||||
|
? getImageUrlsApi(api).getItemImageUrlById(
|
||||||
item.Id ?? "",
|
item.Id ?? "",
|
||||||
"Thumb",
|
"Thumb",
|
||||||
{
|
{
|
||||||
quality: 90,
|
quality: 90,
|
||||||
fillHeight: 360,
|
fillHeight: 360,
|
||||||
},
|
},
|
||||||
) ?? undefined
|
)
|
||||||
|
: undefined
|
||||||
}
|
}
|
||||||
isActive={index === currentSlide}
|
isActive={index === currentSlide}
|
||||||
itemName={item.Name ?? "Unknown"}
|
itemName={item.Name ?? "Unknown"}
|
||||||
@@ -131,6 +133,7 @@ const Carousel = ({
|
|||||||
}
|
}
|
||||||
onTickerClick={handleTickerClick}
|
onTickerClick={handleTickerClick}
|
||||||
index={index}
|
index={index}
|
||||||
|
itemType={item.Type as BaseItemKind}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
))}
|
))}
|
||||||
|
|||||||
@@ -1,13 +1,16 @@
|
|||||||
|
import type { BaseItemKind } from "@jellyfin/sdk/lib/generated-client";
|
||||||
import { Typography } from "@mui/material";
|
import { Typography } from "@mui/material";
|
||||||
import React from "react";
|
import React from "react";
|
||||||
|
import { getTypeIcon } from "../utils/iconsCollection";
|
||||||
|
|
||||||
type CarouselTickersProps = {
|
type CarouselTickersProps = {
|
||||||
imageUrl?: string;
|
imageUrl?: string | undefined | null;
|
||||||
itemName: string;
|
itemName: string;
|
||||||
itemYear: string;
|
itemYear: string;
|
||||||
onTickerClick: (index: number) => void;
|
onTickerClick: (index: number) => void;
|
||||||
index: number;
|
index: number;
|
||||||
isActive: boolean;
|
isActive: boolean;
|
||||||
|
itemType: BaseItemKind;
|
||||||
};
|
};
|
||||||
|
|
||||||
const CarouselTickers = React.memo(
|
const CarouselTickers = React.memo(
|
||||||
@@ -18,6 +21,7 @@ const CarouselTickers = React.memo(
|
|||||||
onTickerClick,
|
onTickerClick,
|
||||||
index,
|
index,
|
||||||
isActive,
|
isActive,
|
||||||
|
itemType,
|
||||||
}: CarouselTickersProps) => {
|
}: CarouselTickersProps) => {
|
||||||
const handleClick = React.useCallback(() => {
|
const handleClick = React.useCallback(() => {
|
||||||
onTickerClick(index);
|
onTickerClick(index);
|
||||||
@@ -28,12 +32,18 @@ const CarouselTickers = React.memo(
|
|||||||
className={`carousel-ticker${isActive ? " active" : ""}`}
|
className={`carousel-ticker${isActive ? " active" : ""}`}
|
||||||
onClick={handleClick}
|
onClick={handleClick}
|
||||||
>
|
>
|
||||||
|
{imageUrl ? (
|
||||||
<img
|
<img
|
||||||
src={imageUrl}
|
src={imageUrl}
|
||||||
alt={itemName}
|
alt={itemName}
|
||||||
className="carousel-ticker-image"
|
className="carousel-ticker-image"
|
||||||
// style={{ width: "5em", height: "100%", objectFit: "cover" }}
|
|
||||||
/>
|
/>
|
||||||
|
) : (
|
||||||
|
<div className="carousel-ticker-image placeholder material-symbols-rounded">
|
||||||
|
{" "}
|
||||||
|
{getTypeIcon(itemType)}
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
<div>
|
<div>
|
||||||
<Typography variant="subtitle1" className="carousel-ticker-title">
|
<Typography variant="subtitle1" className="carousel-ticker-title">
|
||||||
{itemName}
|
{itemName}
|
||||||
|
|||||||
@@ -17,10 +17,6 @@ import React, {
|
|||||||
import { delUser } from "@/utils/storage/user";
|
import { delUser } from "@/utils/storage/user";
|
||||||
import { useApiInContext } from "@/utils/store/api";
|
import { useApiInContext } from "@/utils/store/api";
|
||||||
import { useCentralStore } from "@/utils/store/central";
|
import { useCentralStore } from "@/utils/store/central";
|
||||||
import {
|
|
||||||
setSettingsDialogOpen,
|
|
||||||
setSettingsTabValue,
|
|
||||||
} from "@/utils/store/settings";
|
|
||||||
|
|
||||||
export const UserAvatarMenu = () => {
|
export const UserAvatarMenu = () => {
|
||||||
const api = useApiInContext((s) => s.api);
|
const api = useApiInContext((s) => s.api);
|
||||||
@@ -105,18 +101,6 @@ export const UserAvatarMenu = () => {
|
|||||||
Logout
|
Logout
|
||||||
</MenuItem>
|
</MenuItem>
|
||||||
<Divider />
|
<Divider />
|
||||||
<MenuItem
|
|
||||||
onClick={() => {
|
|
||||||
setSettingsDialogOpen(true);
|
|
||||||
setSettingsTabValue(1);
|
|
||||||
handleMenuClose();
|
|
||||||
}}
|
|
||||||
>
|
|
||||||
<ListItemIcon>
|
|
||||||
<span className="material-symbols-rounded">settings</span>
|
|
||||||
</ListItemIcon>
|
|
||||||
Settings
|
|
||||||
</MenuItem>
|
|
||||||
<MenuItem
|
<MenuItem
|
||||||
onClick={() => {
|
onClick={() => {
|
||||||
navigate({ to: "/settings/preferences" });
|
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 ApiBoxsetIdRouteImport } from './routes/_api/boxset/$id'
|
||||||
import { Route as ApiArtistIdRouteImport } from './routes/_api/artist/$id'
|
import { Route as ApiArtistIdRouteImport } from './routes/_api/artist/$id'
|
||||||
import { Route as ApiAlbumIdRouteImport } from './routes/_api/album/$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'
|
import { Route as ApiLoginUserIdUserNameRouteImport } from './routes/_api/login/$userId.$userName'
|
||||||
|
|
||||||
const ApiRoute = ApiRouteImport.update({
|
const ApiRoute = ApiRouteImport.update({
|
||||||
@@ -172,6 +173,12 @@ const ApiAlbumIdRoute = ApiAlbumIdRouteImport.update({
|
|||||||
path: '/album/$id',
|
path: '/album/$id',
|
||||||
getParentRoute: () => ApiRoute,
|
getParentRoute: () => ApiRoute,
|
||||||
} as any)
|
} as any)
|
||||||
|
const ApiSettingsChangeServerIndexRoute =
|
||||||
|
ApiSettingsChangeServerIndexRouteImport.update({
|
||||||
|
id: '/changeServer/',
|
||||||
|
path: '/changeServer/',
|
||||||
|
getParentRoute: () => ApiSettingsRoute,
|
||||||
|
} as any)
|
||||||
const ApiLoginUserIdUserNameRoute = ApiLoginUserIdUserNameRouteImport.update({
|
const ApiLoginUserIdUserNameRoute = ApiLoginUserIdUserNameRouteImport.update({
|
||||||
id: '/$userId/$userName',
|
id: '/$userId/$userName',
|
||||||
path: '/$userId/$userName',
|
path: '/$userId/$userName',
|
||||||
@@ -206,6 +213,7 @@ export interface FileRoutesByFullPath {
|
|||||||
'/player/': typeof ApiPlayerIndexRoute
|
'/player/': typeof ApiPlayerIndexRoute
|
||||||
'/search/': typeof ApiSearchIndexRoute
|
'/search/': typeof ApiSearchIndexRoute
|
||||||
'/login/$userId/$userName': typeof ApiLoginUserIdUserNameRoute
|
'/login/$userId/$userName': typeof ApiLoginUserIdUserNameRoute
|
||||||
|
'/settings/changeServer/': typeof ApiSettingsChangeServerIndexRoute
|
||||||
}
|
}
|
||||||
export interface FileRoutesByTo {
|
export interface FileRoutesByTo {
|
||||||
'/': typeof IndexRoute
|
'/': typeof IndexRoute
|
||||||
@@ -235,6 +243,7 @@ export interface FileRoutesByTo {
|
|||||||
'/player': typeof ApiPlayerIndexRoute
|
'/player': typeof ApiPlayerIndexRoute
|
||||||
'/search': typeof ApiSearchIndexRoute
|
'/search': typeof ApiSearchIndexRoute
|
||||||
'/login/$userId/$userName': typeof ApiLoginUserIdUserNameRoute
|
'/login/$userId/$userName': typeof ApiLoginUserIdUserNameRoute
|
||||||
|
'/settings/changeServer': typeof ApiSettingsChangeServerIndexRoute
|
||||||
}
|
}
|
||||||
export interface FileRoutesById {
|
export interface FileRoutesById {
|
||||||
__root__: typeof rootRouteImport
|
__root__: typeof rootRouteImport
|
||||||
@@ -266,6 +275,7 @@ export interface FileRoutesById {
|
|||||||
'/_api/player/': typeof ApiPlayerIndexRoute
|
'/_api/player/': typeof ApiPlayerIndexRoute
|
||||||
'/_api/search/': typeof ApiSearchIndexRoute
|
'/_api/search/': typeof ApiSearchIndexRoute
|
||||||
'/_api/login/$userId/$userName': typeof ApiLoginUserIdUserNameRoute
|
'/_api/login/$userId/$userName': typeof ApiLoginUserIdUserNameRoute
|
||||||
|
'/_api/settings/changeServer/': typeof ApiSettingsChangeServerIndexRoute
|
||||||
}
|
}
|
||||||
export interface FileRouteTypes {
|
export interface FileRouteTypes {
|
||||||
fileRoutesByFullPath: FileRoutesByFullPath
|
fileRoutesByFullPath: FileRoutesByFullPath
|
||||||
@@ -297,6 +307,7 @@ export interface FileRouteTypes {
|
|||||||
| '/player/'
|
| '/player/'
|
||||||
| '/search/'
|
| '/search/'
|
||||||
| '/login/$userId/$userName'
|
| '/login/$userId/$userName'
|
||||||
|
| '/settings/changeServer/'
|
||||||
fileRoutesByTo: FileRoutesByTo
|
fileRoutesByTo: FileRoutesByTo
|
||||||
to:
|
to:
|
||||||
| '/'
|
| '/'
|
||||||
@@ -326,6 +337,7 @@ export interface FileRouteTypes {
|
|||||||
| '/player'
|
| '/player'
|
||||||
| '/search'
|
| '/search'
|
||||||
| '/login/$userId/$userName'
|
| '/login/$userId/$userName'
|
||||||
|
| '/settings/changeServer'
|
||||||
id:
|
id:
|
||||||
| '__root__'
|
| '__root__'
|
||||||
| '/'
|
| '/'
|
||||||
@@ -356,6 +368,7 @@ export interface FileRouteTypes {
|
|||||||
| '/_api/player/'
|
| '/_api/player/'
|
||||||
| '/_api/search/'
|
| '/_api/search/'
|
||||||
| '/_api/login/$userId/$userName'
|
| '/_api/login/$userId/$userName'
|
||||||
|
| '/_api/settings/changeServer/'
|
||||||
fileRoutesById: FileRoutesById
|
fileRoutesById: FileRoutesById
|
||||||
}
|
}
|
||||||
export interface RootRouteChildren {
|
export interface RootRouteChildren {
|
||||||
@@ -558,6 +571,13 @@ declare module '@tanstack/react-router' {
|
|||||||
preLoaderRoute: typeof ApiAlbumIdRouteImport
|
preLoaderRoute: typeof ApiAlbumIdRouteImport
|
||||||
parentRoute: typeof ApiRoute
|
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': {
|
'/_api/login/$userId/$userName': {
|
||||||
id: '/_api/login/$userId/$userName'
|
id: '/_api/login/$userId/$userName'
|
||||||
path: '/$userId/$userName'
|
path: '/$userId/$userName'
|
||||||
@@ -587,11 +607,13 @@ const ApiLoginRouteWithChildren = ApiLoginRoute._addFileChildren(
|
|||||||
interface ApiSettingsRouteChildren {
|
interface ApiSettingsRouteChildren {
|
||||||
ApiSettingsAboutRoute: typeof ApiSettingsAboutRoute
|
ApiSettingsAboutRoute: typeof ApiSettingsAboutRoute
|
||||||
ApiSettingsPreferencesRoute: typeof ApiSettingsPreferencesRoute
|
ApiSettingsPreferencesRoute: typeof ApiSettingsPreferencesRoute
|
||||||
|
ApiSettingsChangeServerIndexRoute: typeof ApiSettingsChangeServerIndexRoute
|
||||||
}
|
}
|
||||||
|
|
||||||
const ApiSettingsRouteChildren: ApiSettingsRouteChildren = {
|
const ApiSettingsRouteChildren: ApiSettingsRouteChildren = {
|
||||||
ApiSettingsAboutRoute: ApiSettingsAboutRoute,
|
ApiSettingsAboutRoute: ApiSettingsAboutRoute,
|
||||||
ApiSettingsPreferencesRoute: ApiSettingsPreferencesRoute,
|
ApiSettingsPreferencesRoute: ApiSettingsPreferencesRoute,
|
||||||
|
ApiSettingsChangeServerIndexRoute: ApiSettingsChangeServerIndexRoute,
|
||||||
}
|
}
|
||||||
|
|
||||||
const ApiSettingsRouteWithChildren = ApiSettingsRoute._addFileChildren(
|
const ApiSettingsRouteWithChildren = ApiSettingsRoute._addFileChildren(
|
||||||
|
|||||||
@@ -3,10 +3,12 @@ import React, { useCallback, useMemo } from "react";
|
|||||||
|
|
||||||
import "./home.scss";
|
import "./home.scss";
|
||||||
|
|
||||||
|
import type { Api } from "@jellyfin/sdk";
|
||||||
import {
|
import {
|
||||||
type BaseItemDto,
|
type BaseItemDto,
|
||||||
BaseItemKind,
|
BaseItemKind,
|
||||||
ItemFields,
|
ItemFields,
|
||||||
|
type UserDto,
|
||||||
} from "@jellyfin/sdk/lib/generated-client";
|
} from "@jellyfin/sdk/lib/generated-client";
|
||||||
import { getItemsApi } from "@jellyfin/sdk/lib/utils/api/items-api";
|
import { getItemsApi } from "@jellyfin/sdk/lib/utils/api/items-api";
|
||||||
import { getTvShowsApi } from "@jellyfin/sdk/lib/utils/api/tv-shows-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 api = useApiInContext((s) => s.api);
|
||||||
const user = useCentralStore((s) => s.currentUser);
|
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({
|
const libraries = useSuspenseQuery({
|
||||||
queryKey: ["libraries"],
|
queryKey: ["libraries"],
|
||||||
queryFn: async () => {
|
queryFn: async () => {
|
||||||
if (!api || !user?.Id) return null;
|
|
||||||
const libs = await getUserViewsApi(api).getUserViews({
|
const libs = await getUserViewsApi(api).getUserViews({
|
||||||
userId: user.Id,
|
userId: user.Id,
|
||||||
});
|
});
|
||||||
@@ -52,12 +61,13 @@ function Home() {
|
|||||||
networkMode: "always",
|
networkMode: "always",
|
||||||
});
|
});
|
||||||
|
|
||||||
const latestMedia = useSuspenseQuery(getLatestItemsQueryOptions(api, user?.Id));
|
const latestMedia = useSuspenseQuery(
|
||||||
|
getLatestItemsQueryOptions(api, user.Id),
|
||||||
|
);
|
||||||
|
|
||||||
const resumeItemsVideo = useSuspenseQuery({
|
const resumeItemsVideo = useSuspenseQuery({
|
||||||
queryKey: ["home", "resume", "video"],
|
queryKey: ["home", "resume", "video"],
|
||||||
queryFn: async () => {
|
queryFn: async () => {
|
||||||
if (!api || !user?.Id) return null;
|
|
||||||
const resumeItems = await getItemsApi(api).getResumeItems({
|
const resumeItems = await getItemsApi(api).getResumeItems({
|
||||||
userId: user.Id,
|
userId: user.Id,
|
||||||
limit: 10,
|
limit: 10,
|
||||||
@@ -72,9 +82,8 @@ function Home() {
|
|||||||
const resumeItemsAudio = useSuspenseQuery({
|
const resumeItemsAudio = useSuspenseQuery({
|
||||||
queryKey: ["home", "resume", "audio"],
|
queryKey: ["home", "resume", "audio"],
|
||||||
queryFn: async () => {
|
queryFn: async () => {
|
||||||
if (!api || !user?.Id) return null;
|
|
||||||
const resumeItems = await getItemsApi(api).getResumeItems({
|
const resumeItems = await getItemsApi(api).getResumeItems({
|
||||||
userId: user?.Id,
|
userId: user.Id,
|
||||||
limit: 10,
|
limit: 10,
|
||||||
mediaTypes: ["Audio"],
|
mediaTypes: ["Audio"],
|
||||||
enableUserData: true,
|
enableUserData: true,
|
||||||
@@ -87,9 +96,8 @@ function Home() {
|
|||||||
const upNextItems = useSuspenseQuery({
|
const upNextItems = useSuspenseQuery({
|
||||||
queryKey: ["home", "upNext"],
|
queryKey: ["home", "upNext"],
|
||||||
queryFn: async () => {
|
queryFn: async () => {
|
||||||
if (!api || !user?.Id) return null;
|
|
||||||
const upNext = await getTvShowsApi(api).getNextUp({
|
const upNext = await getTvShowsApi(api).getNextUp({
|
||||||
userId: user?.Id,
|
userId: user.Id,
|
||||||
fields: [
|
fields: [
|
||||||
ItemFields.PrimaryImageAspectRatio,
|
ItemFields.PrimaryImageAspectRatio,
|
||||||
ItemFields.MediaStreams,
|
ItemFields.MediaStreams,
|
||||||
|
|||||||
@@ -12,9 +12,6 @@ import { useSnackbar } from "notistack";
|
|||||||
import { AvatarImage } from "@/components/avatar/avatar.jsx";
|
import { AvatarImage } from "@/components/avatar/avatar.jsx";
|
||||||
import "./login.scss";
|
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 { useMutation } from "@tanstack/react-query";
|
||||||
import {
|
import {
|
||||||
createFileRoute,
|
createFileRoute,
|
||||||
@@ -27,6 +24,9 @@ import React, {
|
|||||||
useEffect,
|
useEffect,
|
||||||
useState,
|
useState,
|
||||||
} from "react";
|
} 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")({
|
export const Route = createFileRoute("/_api/login/$userId/$userName")({
|
||||||
component: LoginUser,
|
component: LoginUser,
|
||||||
@@ -102,7 +102,13 @@ function LoginUser() {
|
|||||||
}
|
}
|
||||||
createApi(api.basePath, authenticate.data?.AccessToken);
|
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(() => {
|
router.invalidate().finally(() => {
|
||||||
navigate({ to: "/home", replace: true });
|
navigate({ to: "/home", replace: true });
|
||||||
|
|||||||
@@ -63,6 +63,12 @@ function SettingsRoute() {
|
|||||||
primary="Preferences"
|
primary="Preferences"
|
||||||
className="settings-sidebar-list-item"
|
className="settings-sidebar-list-item"
|
||||||
/>
|
/>
|
||||||
|
<ListItemLink
|
||||||
|
to="/settings/changeServer"
|
||||||
|
icon="dns"
|
||||||
|
primary="Servers"
|
||||||
|
className="settings-sidebar-list-item"
|
||||||
|
/>
|
||||||
<ListItemLink
|
<ListItemLink
|
||||||
to="/settings/about"
|
to="/settings/about"
|
||||||
icon="info"
|
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({
|
queryOptions({
|
||||||
queryKey: ["item", id],
|
queryKey: ["item", id],
|
||||||
queryFn: async () => {
|
queryFn: async () => {
|
||||||
if (!api || !userId) {
|
if (!api) {
|
||||||
throw Error("API or User ID is not defined");
|
throw Error("API is not defined");
|
||||||
|
}
|
||||||
|
if (!userId) {
|
||||||
|
throw Error("User ID is not defined");
|
||||||
}
|
}
|
||||||
const result = await getUserLibraryApi(api).getItem({
|
const result = await getUserLibraryApi(api).getItem({
|
||||||
userId: userId,
|
userId: userId,
|
||||||
@@ -42,8 +45,11 @@ export const getLatestItemsQueryOptions = (
|
|||||||
queryOptions({
|
queryOptions({
|
||||||
queryKey: ["home", "latestMedia"],
|
queryKey: ["home", "latestMedia"],
|
||||||
queryFn: async () => {
|
queryFn: async () => {
|
||||||
if (!api || !userId) {
|
if (!api) {
|
||||||
throw Error("API or User ID is not defined");
|
throw Error("API is not defined");
|
||||||
|
}
|
||||||
|
if (!userId) {
|
||||||
|
throw Error("User ID is not defined");
|
||||||
}
|
}
|
||||||
const media = await getUserLibraryApi(api).getLatestMedia({
|
const media = await getUserLibraryApi(api).getLatestMedia({
|
||||||
userId: userId,
|
userId: userId,
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ export interface UserStore {
|
|||||||
user: {
|
user: {
|
||||||
Name: string;
|
Name: string;
|
||||||
AccessToken: string;
|
AccessToken: string;
|
||||||
|
Id: string;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -12,10 +13,15 @@ const user = await load(".user.dat", { autoSave: true });
|
|||||||
/**
|
/**
|
||||||
* Set User details to .user.dat
|
* 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", {
|
user.set("user", {
|
||||||
Name: userName,
|
Name: userName,
|
||||||
AccessToken: accessToken,
|
AccessToken: accessToken,
|
||||||
|
Id: userId,
|
||||||
});
|
});
|
||||||
|
|
||||||
await user.save();
|
await user.save();
|
||||||
|
|||||||
@@ -1,17 +1,21 @@
|
|||||||
import type { Api } from "@jellyfin/sdk";
|
import type { Api } from "@jellyfin/sdk";
|
||||||
import type { UserDto } from "@jellyfin/sdk/lib/generated-client";
|
import type { UserDto } from "@jellyfin/sdk/lib/generated-client";
|
||||||
import { getUserApi } from "@jellyfin/sdk/lib/utils/api/user-api";
|
import { getUserApi } from "@jellyfin/sdk/lib/utils/api/user-api";
|
||||||
import React, { type ReactNode } from "react";
|
import React, {
|
||||||
import { createContext, useContext, useState } from "react";
|
createContext,
|
||||||
import { type StoreApi, createStore } from "zustand";
|
type ReactNode,
|
||||||
|
useContext,
|
||||||
|
useState,
|
||||||
|
} from "react";
|
||||||
|
import { createStore, type StoreApi } from "zustand";
|
||||||
import { shallow } from "zustand/shallow";
|
import { shallow } from "zustand/shallow";
|
||||||
import { useStoreWithEqualityFn } from "zustand/traditional";
|
import { useStoreWithEqualityFn } from "zustand/traditional";
|
||||||
import { version } from "../../../package.json";
|
import { version } from "../../../package.json";
|
||||||
import {
|
import {
|
||||||
type ServerInfo,
|
|
||||||
getAllServers,
|
getAllServers,
|
||||||
getDefaultServer,
|
getDefaultServer,
|
||||||
getServer,
|
getServer,
|
||||||
|
type ServerInfo,
|
||||||
} from "../storage/servers";
|
} from "../storage/servers";
|
||||||
import { getUser } from "../storage/user";
|
import { getUser } from "../storage/user";
|
||||||
|
|
||||||
@@ -22,6 +26,7 @@ type CentralStore = {
|
|||||||
userOnDisk: () => Promise<{
|
userOnDisk: () => Promise<{
|
||||||
Name: string;
|
Name: string;
|
||||||
AccessToken: string;
|
AccessToken: string;
|
||||||
|
Id: string;
|
||||||
} | null>;
|
} | null>;
|
||||||
clientVersion: string;
|
clientVersion: string;
|
||||||
currentUser: null | UserDto;
|
currentUser: null | UserDto;
|
||||||
|
|||||||
Reference in new issue
Block a user