From ee1b0536c7f7d60fe02d120511abb5b3522a2d55 Mon Sep 17 00:00:00 2001 From: glax Date: Mon, 4 Aug 2025 11:39:02 +0200 Subject: [PATCH] Reorganize Settings for faster access to individual settings (group them by category) --- .../Settings/AddNotificationConnector.tsx | 42 +++++++++++-------- .../Settings/ChapterNamingScheme.tsx | 11 ++--- .../src/Components/Settings/Download.tsx | 14 +++++++ .../Components/Settings/DownloadLanguage.tsx | 9 ++-- .../src/Components/Settings/FlareSolverr.tsx | 36 +++++++++------- .../Components/Settings/ImageCompression.tsx | 9 ++-- .../src/Components/Settings/Maintenance.tsx | 2 - .../Settings/NotificationConnectors.tsx | 16 ------- .../src/Components/Settings/Services.tsx | 15 +++++++ .../src/Components/Settings/Settings.tsx | 27 ++++++------ 10 files changed, 104 insertions(+), 77 deletions(-) create mode 100644 tranga-website/src/Components/Settings/Download.tsx delete mode 100644 tranga-website/src/Components/Settings/NotificationConnectors.tsx create mode 100644 tranga-website/src/Components/Settings/Services.tsx diff --git a/tranga-website/src/Components/Settings/AddNotificationConnector.tsx b/tranga-website/src/Components/Settings/AddNotificationConnector.tsx index 46165db..5f14e25 100644 --- a/tranga-website/src/Components/Settings/AddNotificationConnector.tsx +++ b/tranga-website/src/Components/Settings/AddNotificationConnector.tsx @@ -1,7 +1,7 @@ import {ReactNode, useContext, useState} from "react"; import { ApiContext } from "../../apiClient/ApiContext"; import { - Button, + Button, Card, Input, Modal, ModalDialog, @@ -9,30 +9,36 @@ import { Tab, TabList, TabPanel, - Tabs + Tabs, Typography } from "@mui/joy"; import ModalClose from "@mui/joy/ModalClose"; import {GotifyRecord, NtfyRecord, PushoverRecord} from "../../apiClient/data-contracts.ts"; import {LoadingState, StateColor, StateIndicator} from "../Loading.tsx"; +import * as React from "react"; -export default function ({open, setOpen} : {open: boolean, setOpen: (open: boolean) => void}) { +export default function () { + const [notificationConnectorsOpen, setNotificationConnectorsOpen] = React.useState(false); return ( - setOpen(false)}> - - - - - Gotify - Ntfy - Pushover - - - - - - - + + Notification Connectors + + setNotificationConnectorsOpen(false)}> + + + + + Gotify + Ntfy + Pushover + + + + + + + + ); } diff --git a/tranga-website/src/Components/Settings/ChapterNamingScheme.tsx b/tranga-website/src/Components/Settings/ChapterNamingScheme.tsx index 2109c90..8e7c094 100644 --- a/tranga-website/src/Components/Settings/ChapterNamingScheme.tsx +++ b/tranga-website/src/Components/Settings/ChapterNamingScheme.tsx @@ -1,7 +1,7 @@ import {ReactNode, useContext, useState} from "react"; -import {SettingsContext, SettingsItem} from "./Settings.tsx"; +import {SettingsContext} from "./Settings.tsx"; import {ApiContext} from "../../apiClient/ApiContext.tsx"; -import {ColorPaletteProp, Input} from "@mui/joy"; +import {Card, ColorPaletteProp, Input, Typography} from "@mui/joy"; import * as React from "react"; import MarkdownPreview from "@uiw/react-markdown-preview"; @@ -27,9 +27,10 @@ export default function () : ReactNode { } return ( - - + + Chapter Naming Scheme - + + ); } \ No newline at end of file diff --git a/tranga-website/src/Components/Settings/Download.tsx b/tranga-website/src/Components/Settings/Download.tsx new file mode 100644 index 0000000..4cbd799 --- /dev/null +++ b/tranga-website/src/Components/Settings/Download.tsx @@ -0,0 +1,14 @@ +import {SettingsItem} from "./Settings.tsx"; +import ImageCompression from "./ImageCompression.tsx"; +import DownloadLanguage from "./DownloadLanguage.tsx"; +import ChapterNamingScheme from "./ChapterNamingScheme.tsx"; + +export default function (){ + return ( + + + + + + ) +} \ No newline at end of file diff --git a/tranga-website/src/Components/Settings/DownloadLanguage.tsx b/tranga-website/src/Components/Settings/DownloadLanguage.tsx index 1a81994..1581a27 100644 --- a/tranga-website/src/Components/Settings/DownloadLanguage.tsx +++ b/tranga-website/src/Components/Settings/DownloadLanguage.tsx @@ -1,7 +1,7 @@ import {ReactNode, useContext, useState} from "react"; -import {SettingsContext, SettingsItem} from "./Settings.tsx"; +import {SettingsContext} from "./Settings.tsx"; import {ApiContext} from "../../apiClient/ApiContext.tsx"; -import {ColorPaletteProp, Input} from "@mui/joy"; +import {Card, ColorPaletteProp, Input, Typography} from "@mui/joy"; import * as React from "react"; export default function () : ReactNode { @@ -26,8 +26,9 @@ export default function () : ReactNode { } return ( - + + Download Language - + ); } \ No newline at end of file diff --git a/tranga-website/src/Components/Settings/FlareSolverr.tsx b/tranga-website/src/Components/Settings/FlareSolverr.tsx index 01392b7..bacb574 100644 --- a/tranga-website/src/Components/Settings/FlareSolverr.tsx +++ b/tranga-website/src/Components/Settings/FlareSolverr.tsx @@ -1,6 +1,6 @@ -import {ReactNode, useContext, useState} from "react"; -import {SettingsContext, SettingsItem} from "./Settings.tsx"; -import {ColorPaletteProp, Input} from "@mui/joy"; +import {ReactNode, useCallback, useContext, useState} from "react"; +import {SettingsContext} from "./Settings.tsx"; +import {Button, Card, ColorPaletteProp, Input, Typography} from "@mui/joy"; import * as React from "react"; import {ApiContext} from "../../apiClient/ApiContext.tsx"; @@ -8,26 +8,34 @@ export default function () : ReactNode { const settings = useContext(SettingsContext); const Api = useContext(ApiContext); + const [uriValue, setUriValue] = React.useState(settings?.flareSolverrUrl as string); const [uriColor, setUriColor] = useState("neutral"); const timerRef = React.useRef>(undefined); const uriChanged = (e : React.ChangeEvent) => { clearTimeout(timerRef.current); setUriColor("warning"); timerRef.current = setTimeout(() => { - Api.settingsFlareSolverrUrlCreate(e.target.value) - .then(response => { - if (response.ok) - setUriColor("success"); - else - setUriColor("danger"); - }) - .catch(() => setUriColor("danger")); + setUriValue(e.target.value); }, 1000); } + + const changeUri = useCallback(() => { + Api.settingsFlareSolverrUrlCreate(uriValue) + .then(response => { + if (response.ok) + setUriColor("success"); + else + setUriColor("danger"); + }) + .catch(() => setUriColor("danger")); + }, [uriValue]); return ( - - - + + FlareSolverr + Apply} + /> + ); } \ No newline at end of file diff --git a/tranga-website/src/Components/Settings/ImageCompression.tsx b/tranga-website/src/Components/Settings/ImageCompression.tsx index 01e9d85..60f1504 100644 --- a/tranga-website/src/Components/Settings/ImageCompression.tsx +++ b/tranga-website/src/Components/Settings/ImageCompression.tsx @@ -1,13 +1,14 @@ import {ReactNode, useContext} from "react"; -import {SettingsContext, SettingsItem} from "./Settings.tsx"; -import {Slider} from "@mui/joy"; +import {SettingsContext} from "./Settings.tsx"; +import {Card, Slider, Typography} from "@mui/joy"; export default function () : ReactNode { const settings = useContext(SettingsContext); return ( - + + Image Compression - + ); } \ No newline at end of file diff --git a/tranga-website/src/Components/Settings/Maintenance.tsx b/tranga-website/src/Components/Settings/Maintenance.tsx index 729dd2b..8b5032e 100644 --- a/tranga-website/src/Components/Settings/Maintenance.tsx +++ b/tranga-website/src/Components/Settings/Maintenance.tsx @@ -19,9 +19,7 @@ export default function () { }).catch(_ => setUnusedMangaState(LoadingState.failure)); } - return ( - - - - ); -} \ No newline at end of file diff --git a/tranga-website/src/Components/Settings/Services.tsx b/tranga-website/src/Components/Settings/Services.tsx new file mode 100644 index 0000000..7f5a7a8 --- /dev/null +++ b/tranga-website/src/Components/Settings/Services.tsx @@ -0,0 +1,15 @@ +import {SettingsItem} from "./Settings.tsx"; +import NotificationConnectors from "./AddNotificationConnector.tsx"; +import FlareSolverr from "./FlareSolverr.tsx"; + +export default function(){ + + + + return ( + + + + + ); +} \ No newline at end of file diff --git a/tranga-website/src/Components/Settings/Settings.tsx b/tranga-website/src/Components/Settings/Settings.tsx index 2ee4ffa..ab4c288 100644 --- a/tranga-website/src/Components/Settings/Settings.tsx +++ b/tranga-website/src/Components/Settings/Settings.tsx @@ -6,20 +6,17 @@ import { AccordionSummary, Button, ColorPaletteProp, DialogContent, DialogTitle, Input, - Modal, ModalDialog + Modal, ModalDialog, Stack } from "@mui/joy"; import './Settings.css'; import * as React from "react"; import {createContext, Dispatch, ReactNode, useContext, useEffect, useState} from "react"; import {TrangaSettings} from "../../apiClient/data-contracts.ts"; import {ApiContext} from "../../apiClient/ApiContext.tsx"; -import NotificationConnectors from "./NotificationConnectors.tsx"; import {SxProps} from "@mui/joy/styles/types"; -import ImageCompression from "./ImageCompression.tsx"; -import FlareSolverr from "./FlareSolverr.tsx"; -import DownloadLanguage from "./DownloadLanguage.tsx"; -import ChapterNamingScheme from "./ChapterNamingScheme.tsx"; import Maintenance from "./Maintenance.tsx"; +import Services from "./Services.tsx"; +import Download from './Download.tsx'; export const SettingsContext = createContext(undefined); @@ -69,11 +66,8 @@ export default function Settings({setApiUri} : {setApiUri: Dispatch - - - - - + + @@ -83,12 +77,17 @@ export default function Settings({setApiUri} : {setApiUri: Dispatch + setExpanded(expanded)}> {title} - {children} + + {children} + );