refactor: update UI for setup

This commit is contained in:
--remove-section committed 2026-02-01 17:11:19 +05:30
1 parent 691df70aff
commit 73e3b865ab
8 files changed
+624 -338

No files matched your search

+83 -55
View File
@@ -1,20 +1,19 @@
import React, { type FormEvent, useState } from "react";
import { setDefaultServer, setServer } from "@/utils/storage/servers";
import LoadingButton from "@mui/lab/LoadingButton";
import { yellow } from "@mui/material/colors";
import Grid from "@mui/material/Grid";
import TextField from "@mui/material/TextField";
import Typography from "@mui/material/Typography";
import { useMutation } from "@tanstack/react-query";
import { useSnackbar } from "notistack";
import React, { type FormEvent, useState } from "react";
import { setDefaultServer, setServer } from "@/utils/storage/servers";
import { jellyfin, useApiInContext } from "@/utils/store/api";
import { yellow } from "@mui/material/colors";
import { useMutation } from "@tanstack/react-query";
// SCSS
import "./server.scss";
import { Paper, Stack } from "@mui/material";
import { createFileRoute, useNavigate } from "@tanstack/react-router";
import logo from "../../assets/logoBlackTransparent.png";
export const Route = createFileRoute("/setup/server/add")({
component: ServerSetup,
@@ -66,56 +65,85 @@ function ServerSetup() {
});
return (
<div
className={"centered serverContainer flex flex-column flex-center"}
style={{
opacity: checkServer.isPending ? "0.5" : "1",
transition: "opacity 350ms",
width: "40vw",
}}
>
<div style={{ marginBottom: "1em" }}>
<Typography variant="h3">Add Server</Typography>
</div>
<form
onSubmit={(e) => checkServer.mutate(e)}
className="flex flex-column"
style={{ gap: "1em", width: "100%" }}
>
<TextField
className="textbox"
label="Server Address:"
variant="outlined"
// inputRef={serverIp}
onChange={(event) => {
setServerIp(event.target.value);
}}
/>
<LoadingButton
variant="contained"
sx={{ width: "100%" }}
size="large"
loading={checkServer.isPending}
endIcon={
<span className="material-symbols-rounded">chevron_right</span>
}
loadingPosition="end"
type="submit"
>
Add Server
</LoadingButton>
</form>
<Grid
item
xl={5}
md={6}
<div className="centered serverContainer flex flex-column flex-center">
<Paper
sx={{
p: 4,
width: "100%",
display: "flex",
alignItems: "center",
gap: 1,
opacity: 0.6,
maxWidth: "40em",
backgroundColor: "rgba(20, 20, 30, 0.7)",
backdropFilter: "blur(24px) saturate(180%)",
backgroundImage:
"linear-gradient(rgba(255, 255, 255, 0.05), rgba(255, 255, 255, 0))",
border: "1px solid rgba(255, 255, 255, 0.08)",
boxShadow: "0 20px 50px rgba(0,0,0,0.5)",
borderRadius: 4,
overflow: "hidden",
}}
>
<Stack spacing={2} width="30em" alignItems="center">
<img
src={logo}
alt="Blink"
style={{
width: "200px",
height: "auto",
objectFit: "contain",
}}
/>
<Typography
variant="body1"
color="text.secondary"
textAlign="center"
maxWidth="80%"
sx={{ lineHeight: 1.5 }}
>
Enter your Jellyfin server address to get started
</Typography>
<form
onSubmit={(e) => checkServer.mutate(e)}
className="flex flex-column"
style={{ gap: "1em", width: "100%" }}
>
<TextField
className="textbox"
placeholder="https://jellyfin.example.com"
fullWidth
variant="outlined"
// inputRef={serverIp}
onChange={(event) => {
setServerIp(event.target.value);
}}
InputProps={{
startAdornment: (
<span
className="material-symbols-rounded"
style={{ opacity: 0.5, marginRight: "12px" }}
>
dns
</span>
),
}}
/>
<LoadingButton
variant="contained"
sx={{ width: "100%", borderRadius: 2, height: 48 }}
size="large"
loading={checkServer.isPending}
type="submit"
>
Connect
</LoadingButton>
</form>
</Stack>
</Paper>
<Stack
direction="row"
spacing={1}
alignItems="center"
sx={{ mt: 3, opacity: 0.6 }}
>
<span
className="material-symbols-rounded"
@@ -128,7 +156,7 @@ function ServerSetup() {
<Typography variant="subtitle1">
Example: https://demo.jellyfin.org/stable
</Typography>
</Grid>
</Stack>
</div>
);
}
+126 -114
View File
@@ -1,21 +1,7 @@
import React, { useLayoutEffect, useState } from "react";
import Chip from "@mui/material/Chip";
import IconButton from "@mui/material/IconButton";
import Paper from "@mui/material/Paper";
import Typography from "@mui/material/Typography";
import { red } from "@mui/material/colors";
import AppBarBackOnly from "@/components/appBar/backOnly";
import {
type ServerInfo,
delServer,
getAllServers,
getDefaultServer,
setDefaultServer,
} from "@/utils/storage/servers";
import { delUser } from "@/utils/storage/user";
import { useBackdropStore } from "@/utils/store/backdrop";
import { useMutation, useQuery, useQueryClient } from "@tanstack/react-query";
import {
createFileRoute,
@@ -23,7 +9,19 @@ import {
useRouter,
} from "@tanstack/react-router";
import { useSnackbar } from "notistack";
import React, { useLayoutEffect, useState } from "react";
import AppBarBackOnly from "@/components/appBar/backOnly";
import {
delServer,
getAllServers,
getDefaultServer,
type ServerInfo,
setDefaultServer,
} from "@/utils/storage/servers";
import { delUser } from "@/utils/storage/user";
import { useBackdropStore } from "@/utils/store/backdrop";
import "./serverList.scss";
import { useShallow } from "zustand/shallow";
import AddServerDialog from "@/components/addServerDialog";
import { useApiInContext } from "@/utils/store/api";
@@ -95,124 +93,138 @@ function ServerList() {
await defaultServer.refetch();
};
const setBackdrop = useBackdropStore((state) => state.setBackdrop);
const setBackdrop = useBackdropStore(
useShallow((state) => state.setBackdrop),
);
useLayoutEffect(() => {
setBackdrop("", "");
setBackdrop("");
}, []);
const [addServerDialog, setAddServerDialog] = useState(false);
return (
<div className="server-list">
<div className="server-list flex flex-column flex-center centered">
<AppBarBackOnly />
<div
style={{
<Paper
sx={{
p: 4,
width: "100%",
maxWidth: "600px",
backgroundColor: "rgba(20, 20, 30, 0.7)",
backdropFilter: "blur(24px) saturate(180%)",
backgroundImage:
"linear-gradient(rgba(255, 255, 255, 0.05), rgba(255, 255, 255, 0))",
border: "1px solid rgba(255, 255, 255, 0.08)",
boxShadow: "0 20px 50px rgba(0,0,0,0.5)",
borderRadius: 4,
overflow: "hidden",
display: "flex",
justifyContent: "space-between",
width: "40vw",
alignItems: "center",
marginBottom: "2em",
flexDirection: "column",
gap: 3,
}}
>
<Typography variant="h3" fontWeight={200}>
Servers
</Typography>
<IconButton
<div
style={{
fontSize: "1.64em",
display: "flex",
justifyContent: "space-between",
alignItems: "center",
}}
onClick={() => setAddServerDialog(true)}
>
<div className="material-symbols-rounded">add</div>
</IconButton>
<AddServerDialog
open={addServerDialog}
sideEffect={() => servers.refetch()}
setAddServerDialog={setAddServerDialog}
/>
</div>
<Paper className="server-list-container">
{servers.isSuccess &&
servers.data.map((server) => (
<div key={server.id} className="server-list-item">
<div className="material-symbols-rounded server-list-item-icon">
dns
</div>
<div className="server-list-item-info">
<Typography
variant="h6"
fontWeight={400}
sx={{
display: "flex",
alignItems: "center",
}}
>
{server.systemInfo?.ServerName}
{server.id === defaultServer.data && (
<Chip
label={
<Typography variant="caption" fontWeight={700}>
Current
</Typography>
}
color="info"
sx={{
ml: 2,
width: "5.4em",
}}
size="small"
/>
)}
</Typography>
<Typography
variant="subtitle1"
style={{
opacity: 0.7,
}}
fontWeight={300}
>
{server.address}
</Typography>
<Typography
variant="subtitle2"
style={{
opacity: 0.5,
}}
fontWeight={300}
>
Version: {server.systemInfo?.Version}
</Typography>
</div>
<div className="server-list-item-buttons">
<IconButton
style={{
fontSize: "1.64em",
}}
onClick={() => {
handleServerChange.mutate(server);
}}
disabled={handleServerChange.isPending}
>
<div className="material-symbols-rounded">start</div>
</IconButton>
<IconButton
style={{
fontSize: "1.64em",
<Typography variant="h4" fontWeight="bold">
Servers
</Typography>
<IconButton
onClick={() => setAddServerDialog(true)}
sx={{
bgcolor: "rgba(255,255,255,0.05)",
"&:hover": { bgcolor: "rgba(255,255,255,0.1)" },
}}
>
<span className="material-symbols-rounded">add</span>
</IconButton>
</div>
color: red[400],
}}
disabled={handleServerChange.isPending}
onClick={() => {
handleDelete(server);
}}
<div className="flex flex-column" style={{ gap: "1em" }}>
{servers.isSuccess &&
servers.data.map((server) => (
<div
key={server.id}
className="server-list-item"
style={{
display: "flex",
alignItems: "center",
padding: "16px",
borderRadius: "16px",
backgroundColor: "rgba(0,0,0,0.2)",
border: "1px solid rgba(255,255,255,0.05)",
gap: "16px",
}}
>
<div
className="material-symbols-rounded"
style={{ fontSize: "24px", opacity: 0.7 }}
>
<div className="material-symbols-rounded">delete_forever</div>
</IconButton>
dns
</div>
<div style={{ flex: 1 }}>
<Typography
variant="h6"
fontWeight={600}
sx={{
display: "flex",
alignItems: "center",
gap: 1,
}}
>
{server.systemInfo?.ServerName}
{server.id === defaultServer.data && (
<Chip
label="Current"
color="primary"
size="small"
sx={{ height: 20, fontSize: "0.7rem", fontWeight: 700 }}
/>
)}
</Typography>
<Typography variant="body2" style={{ opacity: 0.7 }} noWrap>
{server.address}
</Typography>
</div>
<div style={{ display: "flex", gap: "8px" }}>
<IconButton
onClick={() => {
handleServerChange.mutate(server);
}}
disabled={handleServerChange.isPending}
size="small"
sx={{
bgcolor: "rgba(255,255,255,0.05)",
"&:hover": { bgcolor: "var(--mui-palette-primary-main)" },
}}
>
<span className="material-symbols-rounded">login</span>
</IconButton>
<IconButton
onClick={() => handleDelete(server)}
size="small"
sx={{
bgcolor: "rgba(255,255,255,0.05)",
"&:hover": { bgcolor: "var(--mui-palette-error-main)" },
}}
>
<span className="material-symbols-rounded">delete</span>
</IconButton>
</div>
</div>
</div>
))}
))}
</div>
</Paper>
<AddServerDialog
open={addServerDialog}
sideEffect={() => servers.refetch()}
setAddServerDialog={setAddServerDialog}
/>
</div>
);
}