feat: add new about page
This commit is contained in:
9 files changed
+238
-48
No files matched your search
Binary file not shown.
|
After Width: | Height: | Size: 24 KiB |
@@ -1,11 +1,4 @@
|
||||
import React, {
|
||||
type MouseEventHandler,
|
||||
useCallback,
|
||||
useMemo,
|
||||
type ReactNode,
|
||||
} from "react";
|
||||
import { useEffect, useState } from "react";
|
||||
|
||||
import { getUserViewsApi } from "@jellyfin/sdk/lib/utils/api/user-views-api";
|
||||
import MuiAppBar from "@mui/material/AppBar";
|
||||
import Avatar from "@mui/material/Avatar";
|
||||
import IconButton from "@mui/material/IconButton";
|
||||
@@ -13,22 +6,21 @@ import ListItemIcon from "@mui/material/ListItemIcon";
|
||||
import Menu from "@mui/material/Menu";
|
||||
import MenuItem from "@mui/material/MenuItem";
|
||||
import useScrollTrigger from "@mui/material/useScrollTrigger";
|
||||
|
||||
import {
|
||||
Link,
|
||||
useLocation,
|
||||
useNavigate,
|
||||
useRouter,
|
||||
} from "@tanstack/react-router";
|
||||
|
||||
import { getUserViewsApi } from "@jellyfin/sdk/lib/utils/api/user-views-api";
|
||||
|
||||
import { useQuery, useQueryClient } from "@tanstack/react-query";
|
||||
|
||||
import { useLocation, useNavigate, useRouter } from "@tanstack/react-router";
|
||||
import React, {
|
||||
type MouseEventHandler,
|
||||
useCallback,
|
||||
useEffect,
|
||||
useMemo,
|
||||
useState,
|
||||
} from "react";
|
||||
|
||||
import { delUser } from "@/utils/storage/user";
|
||||
import "./appBar.scss";
|
||||
|
||||
import { getTypeIcon } from "../utils/iconsCollection";
|
||||
import { Divider, Drawer, List, ListItem, ListItemButton } from "@mui/material";
|
||||
|
||||
import { useApiInContext } from "@/utils/store/api";
|
||||
import { useCentralStore } from "@/utils/store/central";
|
||||
@@ -36,16 +28,9 @@ import {
|
||||
setSettingsDialogOpen,
|
||||
setSettingsTabValue,
|
||||
} from "@/utils/store/settings";
|
||||
import {
|
||||
Divider,
|
||||
Drawer,
|
||||
List,
|
||||
ListItem,
|
||||
ListItemButton,
|
||||
ListItemText,
|
||||
} from "@mui/material";
|
||||
import BackButton from "../buttons/backButton";
|
||||
import ListItemLink from "../listItemLink";
|
||||
import { getTypeIcon } from "../utils/iconsCollection";
|
||||
|
||||
|
||||
const MemoizeBackButton = React.memo(BackButton);
|
||||
@@ -262,7 +247,6 @@ export const AppBar = () => {
|
||||
<MenuItem
|
||||
onClick={() => {
|
||||
navigate({ to: "/settings/preferences" });
|
||||
setSettingsTabValue(1);
|
||||
handleMenuClose();
|
||||
}}
|
||||
>
|
||||
@@ -273,8 +257,7 @@ export const AppBar = () => {
|
||||
</MenuItem>
|
||||
<MenuItem
|
||||
onClick={() => {
|
||||
setSettingsDialogOpen(true);
|
||||
setSettingsTabValue(10);
|
||||
navigate({ to: "/settings/about" });
|
||||
handleMenuClose();
|
||||
}}
|
||||
>
|
||||
@@ -319,7 +302,10 @@ export const AppBar = () => {
|
||||
<ListItemLink
|
||||
className="library-drawer-item"
|
||||
key={library.Id}
|
||||
to={`/library/${library.Id}`}
|
||||
to="/library/$id"
|
||||
params={{
|
||||
id: library.Id ?? "",
|
||||
}}
|
||||
icon={
|
||||
library.CollectionType &&
|
||||
getTypeIcon(library.CollectionType)
|
||||
|
||||
@@ -1,19 +1,46 @@
|
||||
import { ListItem, ListItemButton, ListItemText } from "@mui/material";
|
||||
import { Link, type ReactNode } from "@tanstack/react-router";
|
||||
import React from "react";
|
||||
import {
|
||||
ListItem,
|
||||
ListItemButton,
|
||||
type ListItemProps,
|
||||
ListItemText,
|
||||
} from "@mui/material";
|
||||
import { createLink, Link } from "@tanstack/react-router";
|
||||
import React, { forwardRef, type ReactNode } from "react";
|
||||
|
||||
interface ListItemLinkProps {
|
||||
interface MUIListItemLinkProps extends ListItemProps<"a"> {
|
||||
icon?: ReactNode;
|
||||
primary: string;
|
||||
to: string;
|
||||
className?: string;
|
||||
}
|
||||
export default function ListItemLink(props: ListItemLinkProps) {
|
||||
|
||||
const CreatedListItemLink = forwardRef<HTMLAnchorElement, MUIListItemLinkProps>(
|
||||
(props, ref) => (
|
||||
<ListItem component="a" ref={ref} {...props}>
|
||||
<ListItemButton
|
||||
style={{
|
||||
borderRadius: "100px",
|
||||
gap: "0.85em",
|
||||
color: "white",
|
||||
textDecoration: "none",
|
||||
}}
|
||||
>
|
||||
<div className="material-symbols-rounded">{props.icon}</div>
|
||||
<ListItemText primary={props.primary} />
|
||||
</ListItemButton>
|
||||
</ListItem>
|
||||
),
|
||||
);
|
||||
|
||||
const ListItemLink = createLink(CreatedListItemLink);
|
||||
|
||||
export default ListItemLink;
|
||||
|
||||
/* export default function ListItemLink(props: ListItemLinkProps) {
|
||||
const { icon, primary, to, className } = props;
|
||||
|
||||
return (
|
||||
<li>
|
||||
{/* @ts-ignore */}
|
||||
{/* @ts-ignore /*}
|
||||
<ListItem
|
||||
component={Link}
|
||||
activeClassName="active"
|
||||
@@ -35,3 +62,4 @@ export default function ListItemLink(props: ListItemLinkProps) {
|
||||
</li>
|
||||
);
|
||||
}
|
||||
*/
|
||||
@@ -22,6 +22,7 @@ import { Route as SetupServerListRouteImport } from './routes/setup/server.list'
|
||||
import { Route as SetupServerErrorRouteImport } from './routes/setup/server.error'
|
||||
import { Route as SetupServerAddRouteImport } from './routes/setup/server.add'
|
||||
import { Route as ApiSettingsPreferencesRouteImport } from './routes/_api/settings/preferences'
|
||||
import { Route as ApiSettingsAboutRouteImport } from './routes/_api/settings/about'
|
||||
import { Route as ApiSeriesIdRouteImport } from './routes/_api/series/$id'
|
||||
import { Route as ApiPlaylistIdRouteImport } from './routes/_api/playlist/$id'
|
||||
import { Route as ApiPlayerPhotosRouteImport } from './routes/_api/player/photos'
|
||||
@@ -101,6 +102,11 @@ const ApiSettingsPreferencesRoute = ApiSettingsPreferencesRouteImport.update({
|
||||
path: '/preferences',
|
||||
getParentRoute: () => ApiSettingsRoute,
|
||||
} as any)
|
||||
const ApiSettingsAboutRoute = ApiSettingsAboutRouteImport.update({
|
||||
id: '/about',
|
||||
path: '/about',
|
||||
getParentRoute: () => ApiSettingsRoute,
|
||||
} as any)
|
||||
const ApiSeriesIdRoute = ApiSeriesIdRouteImport.update({
|
||||
id: '/series/$id',
|
||||
path: '/series/$id',
|
||||
@@ -190,6 +196,7 @@ export interface FileRoutesByFullPath {
|
||||
'/player/photos': typeof ApiPlayerPhotosRoute
|
||||
'/playlist/$id': typeof ApiPlaylistIdRoute
|
||||
'/series/$id': typeof ApiSeriesIdRoute
|
||||
'/settings/about': typeof ApiSettingsAboutRoute
|
||||
'/settings/preferences': typeof ApiSettingsPreferencesRoute
|
||||
'/setup/server/add': typeof SetupServerAddRoute
|
||||
'/setup/server/error': typeof SetupServerErrorRoute
|
||||
@@ -218,6 +225,7 @@ export interface FileRoutesByTo {
|
||||
'/player/photos': typeof ApiPlayerPhotosRoute
|
||||
'/playlist/$id': typeof ApiPlaylistIdRoute
|
||||
'/series/$id': typeof ApiSeriesIdRoute
|
||||
'/settings/about': typeof ApiSettingsAboutRoute
|
||||
'/settings/preferences': typeof ApiSettingsPreferencesRoute
|
||||
'/setup/server/add': typeof SetupServerAddRoute
|
||||
'/setup/server/error': typeof SetupServerErrorRoute
|
||||
@@ -248,6 +256,7 @@ export interface FileRoutesById {
|
||||
'/_api/player/photos': typeof ApiPlayerPhotosRoute
|
||||
'/_api/playlist/$id': typeof ApiPlaylistIdRoute
|
||||
'/_api/series/$id': typeof ApiSeriesIdRoute
|
||||
'/_api/settings/about': typeof ApiSettingsAboutRoute
|
||||
'/_api/settings/preferences': typeof ApiSettingsPreferencesRoute
|
||||
'/setup/server/add': typeof SetupServerAddRoute
|
||||
'/setup/server/error': typeof SetupServerErrorRoute
|
||||
@@ -278,6 +287,7 @@ export interface FileRouteTypes {
|
||||
| '/player/photos'
|
||||
| '/playlist/$id'
|
||||
| '/series/$id'
|
||||
| '/settings/about'
|
||||
| '/settings/preferences'
|
||||
| '/setup/server/add'
|
||||
| '/setup/server/error'
|
||||
@@ -306,6 +316,7 @@ export interface FileRouteTypes {
|
||||
| '/player/photos'
|
||||
| '/playlist/$id'
|
||||
| '/series/$id'
|
||||
| '/settings/about'
|
||||
| '/settings/preferences'
|
||||
| '/setup/server/add'
|
||||
| '/setup/server/error'
|
||||
@@ -335,6 +346,7 @@ export interface FileRouteTypes {
|
||||
| '/_api/player/photos'
|
||||
| '/_api/playlist/$id'
|
||||
| '/_api/series/$id'
|
||||
| '/_api/settings/about'
|
||||
| '/_api/settings/preferences'
|
||||
| '/setup/server/add'
|
||||
| '/setup/server/error'
|
||||
@@ -448,6 +460,13 @@ declare module '@tanstack/react-router' {
|
||||
preLoaderRoute: typeof ApiSettingsPreferencesRouteImport
|
||||
parentRoute: typeof ApiSettingsRoute
|
||||
}
|
||||
'/_api/settings/about': {
|
||||
id: '/_api/settings/about'
|
||||
path: '/about'
|
||||
fullPath: '/settings/about'
|
||||
preLoaderRoute: typeof ApiSettingsAboutRouteImport
|
||||
parentRoute: typeof ApiSettingsRoute
|
||||
}
|
||||
'/_api/series/$id': {
|
||||
id: '/_api/series/$id'
|
||||
path: '/series/$id'
|
||||
@@ -566,10 +585,12 @@ const ApiLoginRouteWithChildren = ApiLoginRoute._addFileChildren(
|
||||
)
|
||||
|
||||
interface ApiSettingsRouteChildren {
|
||||
ApiSettingsAboutRoute: typeof ApiSettingsAboutRoute
|
||||
ApiSettingsPreferencesRoute: typeof ApiSettingsPreferencesRoute
|
||||
}
|
||||
|
||||
const ApiSettingsRouteChildren: ApiSettingsRouteChildren = {
|
||||
ApiSettingsAboutRoute: ApiSettingsAboutRoute,
|
||||
ApiSettingsPreferencesRoute: ApiSettingsPreferencesRoute,
|
||||
}
|
||||
|
||||
|
||||
@@ -9,6 +9,8 @@
|
||||
}
|
||||
&-scrollY {
|
||||
padding: 2em;
|
||||
overflow-x: hidden;
|
||||
width: 100%;
|
||||
}
|
||||
}
|
||||
&-form{
|
||||
|
||||
@@ -1,29 +1,25 @@
|
||||
import { useBackdropStore } from "@/utils/store/backdrop";
|
||||
import {
|
||||
Link,
|
||||
Outlet,
|
||||
createFileRoute,
|
||||
useNavigate,
|
||||
} from "@tanstack/react-router";
|
||||
import { createFileRoute, Outlet, useNavigate } from "@tanstack/react-router";
|
||||
import React, { useCallback, useEffect } from "react";
|
||||
import { useBackdropStore } from "@/utils/store/backdrop";
|
||||
|
||||
import "./settings.scss";
|
||||
import { Divider, IconButton, List, Typography } from "@mui/material";
|
||||
import { useShallow } from "zustand/shallow";
|
||||
import BackButton from "@/components/buttons/backButton";
|
||||
import ListItemLink from "@/components/listItemLink";
|
||||
import { useApiInContext } from "@/utils/store/api";
|
||||
import { useCentralStore } from "@/utils/store/central";
|
||||
import { Button, Divider, IconButton, List, Typography } from "@mui/material";
|
||||
|
||||
export const Route = createFileRoute("/_api/settings")({
|
||||
component: SettingsRoute,
|
||||
});
|
||||
|
||||
function SettingsRoute() {
|
||||
const setBackdrop = useBackdropStore((s) => s.setBackdrop);
|
||||
const setBackdrop = useBackdropStore(useShallow((s) => s.setBackdrop));
|
||||
const api = useApiInContext((s) => s.api);
|
||||
const user = useCentralStore((s) => s.currentUser);
|
||||
useEffect(() => {
|
||||
setBackdrop("", "none");
|
||||
setBackdrop("");
|
||||
});
|
||||
const navigate = useNavigate();
|
||||
const handleNavigateHome = useCallback(() => {
|
||||
@@ -67,6 +63,12 @@ function SettingsRoute() {
|
||||
primary="Preferences"
|
||||
className="settings-sidebar-list-item"
|
||||
/>
|
||||
<ListItemLink
|
||||
to="/settings/about"
|
||||
icon="info"
|
||||
primary="About"
|
||||
className="settings-sidebar-list-item"
|
||||
/>
|
||||
</List>
|
||||
</div>
|
||||
<Outlet />
|
||||
|
||||
@@ -0,0 +1,42 @@
|
||||
.settings-about {
|
||||
&-container {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
justify-content: flex-start;
|
||||
width: 100%;
|
||||
}
|
||||
&-logo{
|
||||
width: 60%;
|
||||
object-fit: cover;
|
||||
}
|
||||
&-table{
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: stretch;
|
||||
justify-content: center;
|
||||
width: 100%;
|
||||
max-width: 60%;
|
||||
margin-top: 2em;
|
||||
&-row {
|
||||
display: flex;
|
||||
flex-direction: row;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
padding: 0.5em 1em;
|
||||
border-bottom: 1px solid rgba(255, 255, 255, 0.12);
|
||||
&:last-child {
|
||||
border-bottom: none;
|
||||
}
|
||||
}
|
||||
}
|
||||
&-links {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: flex-start;
|
||||
justify-content: center;
|
||||
width: 100%;
|
||||
max-width: 60%;
|
||||
margin-top: 2em;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,88 @@
|
||||
import { Fab, Link, Typography } from "@mui/material";
|
||||
import { createFileRoute } from "@tanstack/react-router";
|
||||
import React from "react";
|
||||
import blinkLogo from "@/assets/logoBlackTransparent.png";
|
||||
import { version } from "../../../../package.json";
|
||||
|
||||
import "./about.scss";
|
||||
import { useSuspenseQuery } from "@tanstack/react-query";
|
||||
import {
|
||||
getSystemInfoQueryOptions,
|
||||
getUpdateQueryOptions,
|
||||
} from "@/utils/queries/about";
|
||||
import { useApiInContext } from "@/utils/store/api";
|
||||
|
||||
export const Route = createFileRoute("/_api/settings/about")({
|
||||
component: RouteComponent,
|
||||
loader: async ({ context: { queryClient, api } }) => {
|
||||
await queryClient.ensureQueryData(getSystemInfoQueryOptions(api));
|
||||
await queryClient.ensureQueryData(getUpdateQueryOptions);
|
||||
},
|
||||
});
|
||||
|
||||
function RouteComponent() {
|
||||
const api = useApiInContext((s) => s.api);
|
||||
const systemInfo = useSuspenseQuery(getSystemInfoQueryOptions(api));
|
||||
const updateInfo = useSuspenseQuery(getUpdateQueryOptions);
|
||||
|
||||
return (
|
||||
<div className="settings-page-scrollY settings-about-container">
|
||||
{/* <Typography variant="h4">About</Typography> */}
|
||||
<img src={blinkLogo} alt="Blink" className="settings-about-logo" />
|
||||
<Typography sx={{ opacity: 0.8, marginTop: "-4em" }}>
|
||||
v{version}
|
||||
</Typography>
|
||||
<div className="settings-about-table">
|
||||
<div className="settings-about-table-row">
|
||||
<Typography variant="subtitle1">Server Name</Typography>
|
||||
<Typography variant="subtitle1">
|
||||
{systemInfo.data.ServerName}
|
||||
</Typography>
|
||||
</div>
|
||||
<div className="settings-about-table-row">
|
||||
<Typography variant="subtitle1">Jellyfin Version</Typography>
|
||||
<Typography variant="subtitle1">{systemInfo.data.Version}</Typography>
|
||||
</div>
|
||||
<div className="settings-about-table-row">
|
||||
<Typography variant="subtitle1">Update Available</Typography>
|
||||
<Typography variant="subtitle1">
|
||||
{updateInfo.data
|
||||
? `v${updateInfo.data.version}`
|
||||
: "No update available."}
|
||||
</Typography>
|
||||
</div>
|
||||
</div>
|
||||
<div className="settings-about-links">
|
||||
<Typography variant="h6" style={{ marginBottom: "0.5em" }}>
|
||||
Links
|
||||
</Typography>
|
||||
<Link href="https://github.com/prayag17/Blink">
|
||||
https://github.com/prayag17/Blink
|
||||
</Link>
|
||||
<Link href="https://jellyfin.org">https://jellyfin.org</Link>
|
||||
</div>
|
||||
<Fab
|
||||
LinkComponent={Link}
|
||||
href="https://github.com/sponsors/prayag17"
|
||||
variant="extended"
|
||||
target="_blank"
|
||||
color="primary"
|
||||
sx={{
|
||||
position: "fixed",
|
||||
bottom: "2em",
|
||||
right: "2em",
|
||||
}}
|
||||
>
|
||||
<span
|
||||
className="material-symbols-rounded fill"
|
||||
style={{
|
||||
marginRight: "0.25em",
|
||||
}}
|
||||
>
|
||||
volunteer_activism
|
||||
</span>
|
||||
Support
|
||||
</Fab>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
import type { Api } from "@jellyfin/sdk";
|
||||
import { getSystemApi } from "@jellyfin/sdk/lib/utils/api/system-api";
|
||||
import { queryOptions } from "@tanstack/react-query";
|
||||
import { check } from "@tauri-apps/plugin-updater";
|
||||
|
||||
export const getSystemInfoQueryOptions = (api: Api | null | undefined) =>
|
||||
queryOptions({
|
||||
queryKey: ["about", "serverInfo"],
|
||||
queryFn: async () => {
|
||||
if (!api) {
|
||||
throw Error("API is not defined");
|
||||
}
|
||||
const result = await getSystemApi(api).getSystemInfo();
|
||||
return result.data;
|
||||
},
|
||||
});
|
||||
|
||||
export const getUpdateQueryOptions = queryOptions({
|
||||
queryKey: ["about", "checkForUpdates"],
|
||||
queryFn: async () => await check(),
|
||||
});
|
||||
Reference in new issue
Block a user