feat(web): Add new About page #258

This commit is contained in:
Prayag Prajapati committed 2024-02-17 16:56:58 +05:30
1 parent bf89f35ddd
commit b155daa83b
34 files changed
+1749 -758

No files matched your search

+524
View File
@@ -0,0 +1,524 @@
import {
Chip,
Dialog,
FormControlLabel,
Link,
Skeleton,
Switch,
Tab,
Tabs,
Typography,
styled,
withStyles,
} from "@mui/material";
import { AnimatePresence, motion, transform } from "framer-motion";
import React, { useState } from "react";
import useSettingsStore, {
setSettingsDialogOpen,
setSettingsTabValue,
} from "../../utils/store/settings";
import logo from "../../assets/logoBlack.png";
import { getSystemApi } from "@jellyfin/sdk/lib/utils/api/system-api";
import { useQuery } from "@tanstack/react-query";
import { useApi } from "../../utils/store/api";
import { useCentralStore } from "../../utils/store/central";
import "./settings.module.scss";
import { LoadingButton } from "@mui/lab";
import { relaunch } from "@tauri-apps/api/process";
import { checkUpdate, installUpdate } from "@tauri-apps/api/updater";
import { enqueueSnackbar, useSnackbar } from "notistack";
const motionConfig = {
forward: {
opacity: 0,
transform: "translateY(-20px)",
},
visible: {
opacity: 1,
transform: "translateY(0px)",
},
backward: {
opacity: 0,
transform: "translateY(20px)",
},
};
const Settings = () => {
const [api] = useApi((state) => [state.api]);
const systemInfo = useQuery({
queryKey: ["about", "systemInfo"],
queryFn: async () => {
const result = await getSystemApi(api).getSystemInfo();
return result.data;
},
enabled: Boolean(api),
});
const updateInfo = useQuery({
queryKey: ["about", "updater"],
queryFn: async () => {
const result = await checkUpdate();
return result;
},
});
const { enqueueSnackbar } = useSnackbar();
const [open, tabValue] = useSettingsStore((state) => [
state.dialogOpen,
state.tabValue,
]);
const [applicationVersion] = useCentralStore((state) => [
state.clientVersion,
]);
const [updating, setUpdating] = useState(false);
const [animDirection, setAnimDirection] = useState("forward");
return (
<Dialog
open={open}
fullWidth
maxWidth="md"
PaperProps={{
className: "settings",
}}
onClose={() => setSettingsDialogOpen(false)}
>
<Tabs
orientation="vertical"
value={tabValue}
onChange={(e, newValue) => {
if (newValue > tabValue) {
setAnimDirection("backward");
} else {
setAnimDirection("forward");
}
setSettingsTabValue(newValue);
}}
style={{
borderRight: "1.2px solid rgb(255 255 255 / 0.1)",
}}
>
<Tab
icon={<span className="material-symbols-rounded">settings</span>}
iconPosition="start"
value={1}
label="General"
className="settings-tab"
sx={{
minHeight: "48px",
height: "48px",
}}
/>
<Tab
icon={<span className="material-symbols-rounded">info</span>}
iconPosition="start"
value={10}
label="About"
className="settings-tab"
sx={{
minHeight: "48px",
height: "48px",
}}
/>
</Tabs>
<AnimatePresence mode="wait">
<motion.div
variants={motionConfig}
initial={animDirection === "backward" ? "backward" : "forward"}
animate="visible"
exit={animDirection === "backward" ? "backward" : "forward"}
key={tabValue}
transition={{
duration: 0.1,
}}
className="settings-scroll "
>
{/* About */}
{tabValue === 10 && (
<div className="settings-container settings-about">
<img src={logo} className="settings-logo" alt="JellyPlayer" />
<div className="settings-grid">
<div className="settings-info-container">
<div className="settings-info">
<Typography>Client Version:</Typography>
<Chip
icon={
<span className="material-symbols-rounded">
{updateInfo.data?.shouldUpdate
? "update"
: "update_disabled"}
</span>
}
label={
<Typography variant="subtitle1">
{applicationVersion}
</Typography>
}
color={
updateInfo.data?.shouldUpdate ? "error" : "success"
}
size="medium"
style={{
width: "fit-content !important",
}}
/>
</div>
<div className="settings-info">
<Typography>Update Available:</Typography>
<Typography>
{updateInfo.isFetching
? "Checking for new updates..."
: updateInfo.data?.shouldUpdate
? updateInfo.data.manifest?.version
: "No update found."}
</Typography>
</div>
<LoadingButton
style={{
marginTop: "auto",
}}
loading={updateInfo.isFetching || updating}
variant="contained"
disabled={!updateInfo.data?.shouldUpdate}
loadingPosition="start"
onClick={async () => {
if (updateInfo.data?.shouldUpdate) {
setUpdating(true);
await installUpdate();
enqueueSnackbar(
"Update has been installed! You need to relaunch JellyPlayer.",
{
variant: "success",
},
);
await relaunch();
}
}}
>
{updateInfo.isFetching
? "Checking for Update..."
: updateInfo.data?.shouldUpdate
? "Update"
: "No Update Found"}
</LoadingButton>
</div>
{systemInfo.isSuccess ? (
<div className="settings-info-container">
<div className="settings-info">
<Typography>Server:</Typography>
<Typography>{systemInfo.data?.ServerName}</Typography>
</div>
<div className="settings-info">
<Typography>Jellyfin Version:</Typography>
<Typography>{systemInfo.data?.Version}</Typography>
</div>
<div className="settings-info">
<Typography>Operating System:</Typography>
<Typography>
{systemInfo.data?.OperatingSystemDisplayName}
</Typography>
</div>
<div className="settings-info">
<Typography>Server Architecture:</Typography>
<Typography>
{systemInfo.data?.SystemArchitecture}
</Typography>
</div>
</div>
) : (
<Skeleton
variant="rectangular"
sx={{
height: "100%",
borderRadius: "10px",
}}
/>
)}
</div>
<div
style={{
marginTop: "1em",
background: "rgb(0 0 0 / 0.3)",
padding: "1em",
borderRadius: "10px",
border: "1px solid rgb(255 255 255 / 0.1)",
}}
>
<Typography variant="h6" fontWeight={300} mb={1}>
Links:
</Typography>
<div
style={{
display: "flex",
flexDirection: "column",
alignItems: "flex-start",
gap: "0.1em",
}}
>
<Link href="https://github.com/prayag17/JellyPlayer">
https://github.com/prayag17/JellyPlayer
</Link>
<Link href="https://jellyfin.org">https://jellyfin.org</Link>
</div>
</div>
</div>
)}
{/* General */}
{tabValue === 1 && (
<div className="settings-container">
<FormControlLabel
value="start"
control={<Switch color="primary" />}
label={
<div className="settings-option-info">
<Typography variant="h6" fontWeight={400}>
Enable DiscordRPC
</Typography>
<Typography variant="subtitle2" fontWeight={200}>
this a test
</Typography>
</div>
}
labelPlacement="start"
className="settings-option"
/>
<FormControlLabel
value="start"
control={<Switch color="primary" />}
label={
<div className="settings-option-info">
<Typography variant="h6" fontWeight={400}>
Enable DiscordRPC
</Typography>
<Typography variant="subtitle2" fontWeight={200}>
this a test
</Typography>
</div>
}
labelPlacement="start"
className="settings-option"
/>
<FormControlLabel
value="start"
control={<Switch color="primary" />}
label={
<div className="settings-option-info">
<Typography variant="h6" fontWeight={400}>
Enable DiscordRPC
</Typography>
<Typography variant="subtitle2" fontWeight={200}>
this a test
</Typography>
</div>
}
labelPlacement="start"
className="settings-option"
/>
<FormControlLabel
value="start"
control={<Switch color="primary" />}
label={
<div className="settings-option-info">
<Typography variant="h6" fontWeight={400}>
Enable DiscordRPC
</Typography>
<Typography variant="subtitle2" fontWeight={200}>
this a test
</Typography>
</div>
}
labelPlacement="start"
className="settings-option"
/>
<FormControlLabel
value="start"
control={<Switch color="primary" />}
label={
<div className="settings-option-info">
<Typography variant="h6" fontWeight={400}>
Enable DiscordRPC
</Typography>
<Typography variant="subtitle2" fontWeight={200}>
this a test
</Typography>
</div>
}
labelPlacement="start"
className="settings-option"
/>
<FormControlLabel
value="start"
control={<Switch color="primary" />}
label={
<div className="settings-option-info">
<Typography variant="h6" fontWeight={400}>
Enable DiscordRPC
</Typography>
<Typography variant="subtitle2" fontWeight={200}>
this a test
</Typography>
</div>
}
labelPlacement="start"
className="settings-option"
/>
<FormControlLabel
value="start"
control={<Switch color="primary" />}
label={
<div className="settings-option-info">
<Typography variant="h6" fontWeight={400}>
Enable DiscordRPC
</Typography>
<Typography variant="subtitle2" fontWeight={200}>
this a test
</Typography>
</div>
}
labelPlacement="start"
className="settings-option"
/>
<FormControlLabel
value="start"
control={<Switch color="primary" />}
label={
<div className="settings-option-info">
<Typography variant="h6" fontWeight={400}>
Enable DiscordRPC
</Typography>
<Typography variant="subtitle2" fontWeight={200}>
this a test
</Typography>
</div>
}
labelPlacement="start"
className="settings-option"
/>
<FormControlLabel
value="start"
control={<Switch color="primary" />}
label={
<div className="settings-option-info">
<Typography variant="h6" fontWeight={400}>
Enable DiscordRPC
</Typography>
<Typography variant="subtitle2" fontWeight={200}>
this a test
</Typography>
</div>
}
labelPlacement="start"
className="settings-option"
/>
<FormControlLabel
value="start"
control={<Switch color="primary" />}
label={
<div className="settings-option-info">
<Typography variant="h6" fontWeight={400}>
Enable DiscordRPC
</Typography>
<Typography variant="subtitle2" fontWeight={200}>
this a test
</Typography>
</div>
}
labelPlacement="start"
className="settings-option"
/>
<FormControlLabel
value="start"
control={<Switch color="primary" />}
label={
<div className="settings-option-info">
<Typography variant="h6" fontWeight={400}>
Enable DiscordRPC
</Typography>
<Typography variant="subtitle2" fontWeight={200}>
this a test
</Typography>
</div>
}
labelPlacement="start"
className="settings-option"
/>
<FormControlLabel
value="start"
control={<Switch color="primary" />}
label={
<div className="settings-option-info">
<Typography variant="h6" fontWeight={400}>
Enable DiscordRPC
</Typography>
<Typography variant="subtitle2" fontWeight={200}>
this a test
</Typography>
</div>
}
labelPlacement="start"
className="settings-option"
/>
<FormControlLabel
value="start"
control={<Switch color="primary" />}
label={
<div className="settings-option-info">
<Typography variant="h6" fontWeight={400}>
Enable DiscordRPC
</Typography>
<Typography variant="subtitle2" fontWeight={200}>
this a test
</Typography>
</div>
}
labelPlacement="start"
className="settings-option"
/>
<FormControlLabel
value="start"
control={<Switch color="primary" />}
label={
<div className="settings-option-info">
<Typography variant="h6" fontWeight={400}>
Enable DiscordRPC
</Typography>
<Typography variant="subtitle2" fontWeight={200}>
this a test
</Typography>
</div>
}
labelPlacement="start"
className="settings-option"
/>
<FormControlLabel
value="start"
control={<Switch color="primary" />}
label={
<div className="settings-option-info">
<Typography variant="h6" fontWeight={400}>
Enable DiscordRPC
</Typography>
<Typography variant="subtitle2" fontWeight={200}>
this a test
</Typography>
</div>
}
labelPlacement="start"
className="settings-option"
/>
</div>
)}
</motion.div>
</AnimatePresence>
</Dialog>
);
};
export default Settings;
@@ -0,0 +1,85 @@
.settings{
display: grid !important;
grid-template-columns: 20% 1fr;
height: 60vh;
overflow: hidden !important;
&-container{
margin: 14px 0em 14px 14px;
}
&-tab{
display: grid !important;
grid-template-columns: 2em 1fr;
align-items: center;
justify-items: start !important;
gap:1em;
& .material-symbols-rounded{
justify-self: center !important;
}
}
&-scroll{
overflow-y: auto;
mask-image: linear-gradient(to top, transparent, black 15px calc(100% - 15px), transparent);
// Magic scrollbar
&::-webkit-scrollbar {
&-thumb {
height: 150px;
max-height: 33%;
}
&-track {
margin-top: 15px;
margin-bottom: 15px;
background: transparent !important;
}
}
}
// About page
&-grid{
display: grid;
grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
gap:1em;
}
&-logo{
width: 100%;
background: rgb(255 255 255 / 1);
padding: 2em;
margin-bottom: 1em;
border-radius: $border-radius-default;
}
&-info{
display: grid;
grid-template-columns: 40% 1fr;
gap: 1em;
justify-items: start;
align-items: center;
&-container{
background: rgb(0 0 0 / 0.3);
border: 1px solid rgb(255 255 255 / 0.1);
padding: 1em;
border-radius: $border-radius-default;
display: flex;
flex-direction: column;
gap:0.4em;
width: 100%;
}
}
//settings
&-option{
display: flex;
align-items: center;
justify-content: space-between;
width: 100%;
padding: 0 !important;
margin: 0 0 0.4em 0!important;
}
}
.Mui-selected .material-symbols-rounded{
font-variation-settings: "FILL" 1, "wght" 300, "GRAD" 25, "opsz" 40;
}