Feature/modify download settings (#429)
* [Codegen] Update settings fragment * Extract logic to change a number setting * Show slider for global update interval setting * Add download settings
This commit is contained in:
@@ -32,6 +32,7 @@ import { Updates } from '@/screens/Updates';
|
|||||||
import '@/i18n';
|
import '@/i18n';
|
||||||
import { LibrarySettings } from '@/screens/settings/LibrarySettings';
|
import { LibrarySettings } from '@/screens/settings/LibrarySettings';
|
||||||
import { DefaultNavBar } from '@/components/navbar/DefaultNavBar';
|
import { DefaultNavBar } from '@/components/navbar/DefaultNavBar';
|
||||||
|
import { DownloadSettings } from '@/screens/settings/DownloadSettings.tsx';
|
||||||
|
|
||||||
if (__DEV__) {
|
if (__DEV__) {
|
||||||
// Adds messages only in a dev environment
|
// Adds messages only in a dev environment
|
||||||
@@ -63,6 +64,7 @@ export const App: React.FC = () => (
|
|||||||
<Route path="categories" element={<Categories />} />
|
<Route path="categories" element={<Categories />} />
|
||||||
<Route path="defaultReaderSettings" element={<DefaultReaderSettings />} />
|
<Route path="defaultReaderSettings" element={<DefaultReaderSettings />} />
|
||||||
<Route path="librarySettings" element={<LibrarySettings />} />
|
<Route path="librarySettings" element={<LibrarySettings />} />
|
||||||
|
<Route path="downloadSettings" element={<DownloadSettings />} />
|
||||||
<Route path="backup" element={<Backup />} />
|
<Route path="backup" element={<Backup />} />
|
||||||
</Route>
|
</Route>
|
||||||
|
|
||||||
|
|||||||
162
src/components/settings/NumberSetting.tsx
Normal file
162
src/components/settings/NumberSetting.tsx
Normal file
@@ -0,0 +1,162 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (C) Contributors to the Suwayomi project
|
||||||
|
*
|
||||||
|
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||||
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||||
|
* file, You can obtain one at https://mozilla.org/MPL/2.0/.
|
||||||
|
*/
|
||||||
|
|
||||||
|
import Dialog from '@mui/material/Dialog';
|
||||||
|
import DialogContent from '@mui/material/DialogContent';
|
||||||
|
import DialogTitle from '@mui/material/DialogTitle';
|
||||||
|
import TextField from '@mui/material/TextField';
|
||||||
|
import { InputAdornment, ListItemText } from '@mui/material';
|
||||||
|
import DialogActions from '@mui/material/DialogActions';
|
||||||
|
import Button from '@mui/material/Button';
|
||||||
|
import { useCallback, useEffect, useState } from 'react';
|
||||||
|
import { useTranslation } from 'react-i18next';
|
||||||
|
import ListItemButton from '@mui/material/ListItemButton';
|
||||||
|
import * as React from 'react';
|
||||||
|
import ListItemIcon from '@mui/material/ListItemIcon';
|
||||||
|
import Slider from '@mui/material/Slider';
|
||||||
|
|
||||||
|
type BaseProps = {
|
||||||
|
settingTitle: string;
|
||||||
|
settingValue: string;
|
||||||
|
settingIcon?: React.ReactNode;
|
||||||
|
value: number;
|
||||||
|
defaultValue?: number;
|
||||||
|
minValue?: number;
|
||||||
|
maxValue?: number;
|
||||||
|
stepSize?: number;
|
||||||
|
dialogTitle: string;
|
||||||
|
valueUnit: string;
|
||||||
|
handleUpdate: (value: number) => void;
|
||||||
|
showSlider?: never;
|
||||||
|
};
|
||||||
|
|
||||||
|
type PropsWithSlider = Omit<BaseProps, 'defaultValue' | 'minValue' | 'maxValue' | 'showSlider'> &
|
||||||
|
Required<Pick<BaseProps, 'defaultValue' | 'minValue' | 'maxValue'>> & { showSlider: true };
|
||||||
|
|
||||||
|
type Props = BaseProps | PropsWithSlider;
|
||||||
|
|
||||||
|
export const NumberSetting = ({
|
||||||
|
settingTitle,
|
||||||
|
settingValue,
|
||||||
|
settingIcon,
|
||||||
|
value,
|
||||||
|
defaultValue,
|
||||||
|
minValue,
|
||||||
|
maxValue,
|
||||||
|
stepSize,
|
||||||
|
dialogTitle,
|
||||||
|
valueUnit,
|
||||||
|
handleUpdate,
|
||||||
|
showSlider,
|
||||||
|
}: Props) => {
|
||||||
|
const { t } = useTranslation();
|
||||||
|
|
||||||
|
const [isDialogOpen, setIsDialogOpen] = useState(false);
|
||||||
|
const [dialogValue, setDialogValue] = useState(value);
|
||||||
|
|
||||||
|
const closeDialog = useCallback(
|
||||||
|
(resetValue: boolean) => {
|
||||||
|
setIsDialogOpen(false);
|
||||||
|
|
||||||
|
if (resetValue) {
|
||||||
|
setDialogValue(value);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
[value],
|
||||||
|
);
|
||||||
|
|
||||||
|
const closeDialogWithReset = useCallback(() => closeDialog(true), [closeDialog]);
|
||||||
|
|
||||||
|
const updateSetting = useCallback(
|
||||||
|
(newValue: number, shouldCloseDialog: boolean = true) => {
|
||||||
|
if (shouldCloseDialog) {
|
||||||
|
closeDialog(false);
|
||||||
|
}
|
||||||
|
|
||||||
|
const didValueChange = value !== newValue;
|
||||||
|
if (!didValueChange) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
handleUpdate(newValue);
|
||||||
|
},
|
||||||
|
[value, handleUpdate, closeDialog],
|
||||||
|
);
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
setDialogValue(value);
|
||||||
|
}, [value]);
|
||||||
|
|
||||||
|
return (
|
||||||
|
<>
|
||||||
|
<ListItemButton onClick={() => setIsDialogOpen(true)}>
|
||||||
|
{settingIcon ? <ListItemIcon>{settingIcon}</ListItemIcon> : null}
|
||||||
|
<ListItemText
|
||||||
|
primary={settingTitle}
|
||||||
|
secondary={settingValue}
|
||||||
|
secondaryTypographyProps={{ style: { display: 'flex', flexDirection: 'column' } }}
|
||||||
|
/>
|
||||||
|
</ListItemButton>
|
||||||
|
|
||||||
|
<Dialog open={isDialogOpen} onClose={closeDialogWithReset}>
|
||||||
|
<DialogContent>
|
||||||
|
<DialogTitle sx={{ paddingLeft: 0 }}>{dialogTitle}</DialogTitle>
|
||||||
|
<TextField
|
||||||
|
sx={{
|
||||||
|
width: '100%',
|
||||||
|
margin: 'auto',
|
||||||
|
}}
|
||||||
|
InputProps={{
|
||||||
|
inputProps: { min: minValue, max: maxValue, step: stepSize },
|
||||||
|
startAdornment: <InputAdornment position="start">{valueUnit}</InputAdornment>,
|
||||||
|
}}
|
||||||
|
autoFocus
|
||||||
|
value={dialogValue}
|
||||||
|
type="number"
|
||||||
|
onChange={(e) => setDialogValue(Number(e.target.value))}
|
||||||
|
/>
|
||||||
|
{showSlider ? (
|
||||||
|
<Slider
|
||||||
|
aria-label="number-setting-slider"
|
||||||
|
defaultValue={defaultValue}
|
||||||
|
value={dialogValue}
|
||||||
|
step={stepSize}
|
||||||
|
min={minValue}
|
||||||
|
max={maxValue}
|
||||||
|
onChange={(_, newValue) => setDialogValue(newValue as number)}
|
||||||
|
/>
|
||||||
|
) : null}
|
||||||
|
</DialogContent>
|
||||||
|
<DialogActions>
|
||||||
|
{defaultValue !== undefined ? (
|
||||||
|
<Button
|
||||||
|
onClick={() => {
|
||||||
|
setDialogValue(defaultValue);
|
||||||
|
updateSetting(defaultValue, false);
|
||||||
|
}}
|
||||||
|
color="primary"
|
||||||
|
>
|
||||||
|
{t('global.button.reset_to_default')}
|
||||||
|
</Button>
|
||||||
|
) : null}
|
||||||
|
<Button onClick={closeDialogWithReset} color="primary">
|
||||||
|
{t('global.button.cancel')}
|
||||||
|
</Button>
|
||||||
|
<Button
|
||||||
|
onClick={() => {
|
||||||
|
updateSetting(dialogValue);
|
||||||
|
}}
|
||||||
|
color="primary"
|
||||||
|
>
|
||||||
|
{t('global.button.ok')}
|
||||||
|
</Button>
|
||||||
|
</DialogActions>
|
||||||
|
</Dialog>
|
||||||
|
</>
|
||||||
|
);
|
||||||
|
};
|
||||||
87
src/components/settings/ServerDirSetting.tsx
Normal file
87
src/components/settings/ServerDirSetting.tsx
Normal file
@@ -0,0 +1,87 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (C) Contributors to the Suwayomi project
|
||||||
|
*
|
||||||
|
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||||
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||||
|
* file, You can obtain one at https://mozilla.org/MPL/2.0/.
|
||||||
|
*/
|
||||||
|
|
||||||
|
import { Button, Dialog, DialogTitle, ListItemText } from '@mui/material';
|
||||||
|
import DialogContent from '@mui/material/DialogContent';
|
||||||
|
import TextField from '@mui/material/TextField';
|
||||||
|
import DialogActions from '@mui/material/DialogActions';
|
||||||
|
import ListItemButton from '@mui/material/ListItemButton';
|
||||||
|
import { useEffect, useState } from 'react';
|
||||||
|
import { useTranslation } from 'react-i18next';
|
||||||
|
import DialogContentText from '@mui/material/DialogContentText';
|
||||||
|
|
||||||
|
export const ServerDirSetting = ({
|
||||||
|
settingName,
|
||||||
|
dialogDescription,
|
||||||
|
dirPath,
|
||||||
|
handlePathChange,
|
||||||
|
}: {
|
||||||
|
settingName: string;
|
||||||
|
dialogDescription: string;
|
||||||
|
dirPath?: string;
|
||||||
|
handlePathChange: (path: string) => void;
|
||||||
|
}) => {
|
||||||
|
const { t } = useTranslation();
|
||||||
|
|
||||||
|
const [isDialogOpen, setIsDialogOpen] = useState(false);
|
||||||
|
const [dialogDirPath, setDialogDirPath] = useState(dirPath ?? '');
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
if (!dirPath) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
setDialogDirPath(dirPath);
|
||||||
|
}, [dirPath]);
|
||||||
|
|
||||||
|
const closeDialog = () => {
|
||||||
|
setIsDialogOpen(false);
|
||||||
|
};
|
||||||
|
|
||||||
|
const updateSetting = () => {
|
||||||
|
closeDialog();
|
||||||
|
handlePathChange(dialogDirPath);
|
||||||
|
};
|
||||||
|
|
||||||
|
return (
|
||||||
|
<>
|
||||||
|
<ListItemButton onClick={() => setIsDialogOpen(true)}>
|
||||||
|
<ListItemText
|
||||||
|
primary={settingName}
|
||||||
|
secondary={dirPath ?? t('global.label.loading')}
|
||||||
|
secondaryTypographyProps={{ style: { display: 'flex', flexDirection: 'column' } }}
|
||||||
|
/>
|
||||||
|
</ListItemButton>
|
||||||
|
|
||||||
|
<Dialog open={isDialogOpen} onClose={closeDialog} fullWidth>
|
||||||
|
<DialogContent>
|
||||||
|
<DialogTitle sx={{ paddingLeft: 0 }}>{settingName}</DialogTitle>
|
||||||
|
<DialogContentText sx={{ paddingBottom: '10px' }}>{dialogDescription}</DialogContentText>
|
||||||
|
<TextField
|
||||||
|
sx={{
|
||||||
|
width: '100%',
|
||||||
|
margin: 'auto',
|
||||||
|
}}
|
||||||
|
autoFocus
|
||||||
|
value={dialogDirPath}
|
||||||
|
type="text"
|
||||||
|
onChange={(e) => setDialogDirPath(e.target.value)}
|
||||||
|
/>
|
||||||
|
</DialogContent>
|
||||||
|
<DialogActions>
|
||||||
|
<Button onClick={closeDialog} color="primary">
|
||||||
|
{t('global.button.cancel')}
|
||||||
|
</Button>
|
||||||
|
<Button onClick={() => updateSetting()} color="primary">
|
||||||
|
{t('global.button.ok')}
|
||||||
|
</Button>
|
||||||
|
</DialogActions>
|
||||||
|
</Dialog>
|
||||||
|
</>
|
||||||
|
);
|
||||||
|
};
|
||||||
68
src/components/settings/downloads/DownloadAheadSetting.tsx
Normal file
68
src/components/settings/downloads/DownloadAheadSetting.tsx
Normal file
@@ -0,0 +1,68 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (C) Contributors to the Suwayomi project
|
||||||
|
*
|
||||||
|
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||||
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||||
|
* file, You can obtain one at https://mozilla.org/MPL/2.0/.
|
||||||
|
*/
|
||||||
|
|
||||||
|
import { useTranslation } from 'react-i18next';
|
||||||
|
import { List, ListItem, ListItemText, Switch } from '@mui/material';
|
||||||
|
import ListItemSecondaryAction from '@mui/material/ListItemSecondaryAction';
|
||||||
|
import { useCallback } from 'react';
|
||||||
|
import { requestManager } from '@/lib/requests/RequestManager.ts';
|
||||||
|
import { NumberSetting } from '@/components/settings/NumberSetting.tsx';
|
||||||
|
|
||||||
|
const DEFAULT_LIMIT = 5;
|
||||||
|
const MIN_LIMIT = 2;
|
||||||
|
const MAX_LIMIT = 10;
|
||||||
|
|
||||||
|
export const DownloadAheadSetting = () => {
|
||||||
|
const { t } = useTranslation();
|
||||||
|
|
||||||
|
const { data } = requestManager.useGetServerSettings();
|
||||||
|
const downloadAheadLimit = data?.settings.autoDownloadAheadLimit ?? 0;
|
||||||
|
const shouldDownloadAhead = !!downloadAheadLimit;
|
||||||
|
const [mutateSettings] = requestManager.useUpdateServerSettings();
|
||||||
|
|
||||||
|
const updateSetting = useCallback((autoDownloadAheadLimit: number) => {
|
||||||
|
mutateSettings({ variables: { input: { settings: { autoDownloadAheadLimit } } } });
|
||||||
|
}, []);
|
||||||
|
|
||||||
|
const setDoAutoUpdates = (enable: boolean) => {
|
||||||
|
const globalUpdateInterval = enable ? DEFAULT_LIMIT : 0;
|
||||||
|
updateSetting(globalUpdateInterval);
|
||||||
|
};
|
||||||
|
|
||||||
|
return (
|
||||||
|
<List>
|
||||||
|
<ListItem>
|
||||||
|
<ListItemText primary={t('download.settings.download_ahead.label.while_reading')} />
|
||||||
|
<ListItemSecondaryAction>
|
||||||
|
<Switch
|
||||||
|
edge="end"
|
||||||
|
checked={shouldDownloadAhead}
|
||||||
|
onChange={(e) => setDoAutoUpdates(e.target.checked)}
|
||||||
|
/>
|
||||||
|
</ListItemSecondaryAction>
|
||||||
|
</ListItem>
|
||||||
|
{shouldDownloadAhead ? (
|
||||||
|
<NumberSetting
|
||||||
|
settingTitle={t('download.settings.download_ahead.label.unread_chapters_to_download')}
|
||||||
|
settingValue={t('download.settings.download_ahead.label.value', {
|
||||||
|
chapters: downloadAheadLimit,
|
||||||
|
count: downloadAheadLimit,
|
||||||
|
})}
|
||||||
|
value={downloadAheadLimit}
|
||||||
|
minValue={MIN_LIMIT}
|
||||||
|
maxValue={MAX_LIMIT}
|
||||||
|
defaultValue={DEFAULT_LIMIT}
|
||||||
|
showSlider
|
||||||
|
dialogTitle={t('download.settings.download_ahead.label.unread_chapters_to_download')}
|
||||||
|
valueUnit={t('chapter.title')}
|
||||||
|
handleUpdate={updateSetting}
|
||||||
|
/>
|
||||||
|
) : null}
|
||||||
|
</List>
|
||||||
|
);
|
||||||
|
};
|
||||||
@@ -7,20 +7,15 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
import { useTranslation } from 'react-i18next';
|
import { useTranslation } from 'react-i18next';
|
||||||
import { InputAdornment, List, ListItem, ListItemText, Switch } from '@mui/material';
|
import { List, ListItem, ListItemText, Switch } from '@mui/material';
|
||||||
import ListItemSecondaryAction from '@mui/material/ListItemSecondaryAction';
|
import ListItemSecondaryAction from '@mui/material/ListItemSecondaryAction';
|
||||||
import ListItemButton from '@mui/material/ListItemButton';
|
import { useCallback } from 'react';
|
||||||
import { useEffect, useState } from 'react';
|
|
||||||
import DialogContent from '@mui/material/DialogContent';
|
|
||||||
import DialogTitle from '@mui/material/DialogTitle';
|
|
||||||
import DialogActions from '@mui/material/DialogActions';
|
|
||||||
import Button from '@mui/material/Button';
|
|
||||||
import Dialog from '@mui/material/Dialog';
|
|
||||||
import TextField from '@mui/material/TextField';
|
|
||||||
import { requestManager } from '@/lib/requests/RequestManager.ts';
|
import { requestManager } from '@/lib/requests/RequestManager.ts';
|
||||||
|
import { NumberSetting } from '@/components/settings/NumberSetting.tsx';
|
||||||
|
|
||||||
const DEFAULT_INTERVAL_HOURS = 12;
|
const DEFAULT_INTERVAL_HOURS = 12;
|
||||||
const MIN_INTERVAL_HOURS = 6;
|
const MIN_INTERVAL_HOURS = 6;
|
||||||
|
const MAX_INTERVAL_HOURS = 24 * 7 * 4; // 1 month
|
||||||
|
|
||||||
export const GlobalUpdateSettingsInterval = () => {
|
export const GlobalUpdateSettingsInterval = () => {
|
||||||
const { t } = useTranslation();
|
const { t } = useTranslation();
|
||||||
@@ -30,33 +25,15 @@ export const GlobalUpdateSettingsInterval = () => {
|
|||||||
const doAutoUpdates = !!autoUpdateIntervalHours;
|
const doAutoUpdates = !!autoUpdateIntervalHours;
|
||||||
const [mutateSettings] = requestManager.useUpdateServerSettings();
|
const [mutateSettings] = requestManager.useUpdateServerSettings();
|
||||||
|
|
||||||
const [isDialogOpen, setIsDialogOpen] = useState(false);
|
const updateSetting = useCallback((globalUpdateInterval: number) => {
|
||||||
const [dialogUpdateIntervalHours, setDialogUpdateIntervalHours] = useState(autoUpdateIntervalHours);
|
|
||||||
|
|
||||||
const closeDialog = () => {
|
|
||||||
setIsDialogOpen(false);
|
|
||||||
};
|
|
||||||
|
|
||||||
const updateSetting = (globalUpdateInterval: number) => {
|
|
||||||
closeDialog();
|
|
||||||
|
|
||||||
const didIntervalChange = autoUpdateIntervalHours !== globalUpdateInterval;
|
|
||||||
if (!didIntervalChange) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
mutateSettings({ variables: { input: { settings: { globalUpdateInterval } } } });
|
mutateSettings({ variables: { input: { settings: { globalUpdateInterval } } } });
|
||||||
};
|
}, []);
|
||||||
|
|
||||||
const setDoAutoUpdates = (enable: boolean) => {
|
const setDoAutoUpdates = (enable: boolean) => {
|
||||||
const globalUpdateInterval = enable ? DEFAULT_INTERVAL_HOURS : 0;
|
const globalUpdateInterval = enable ? DEFAULT_INTERVAL_HOURS : 0;
|
||||||
updateSetting(globalUpdateInterval);
|
updateSetting(globalUpdateInterval);
|
||||||
};
|
};
|
||||||
|
|
||||||
useEffect(() => {
|
|
||||||
setDialogUpdateIntervalHours(autoUpdateIntervalHours);
|
|
||||||
}, [autoUpdateIntervalHours]);
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<List>
|
<List>
|
||||||
<ListItem>
|
<ListItem>
|
||||||
@@ -66,54 +43,20 @@ export const GlobalUpdateSettingsInterval = () => {
|
|||||||
</ListItemSecondaryAction>
|
</ListItemSecondaryAction>
|
||||||
</ListItem>
|
</ListItem>
|
||||||
{doAutoUpdates ? (
|
{doAutoUpdates ? (
|
||||||
<>
|
<NumberSetting
|
||||||
<ListItemButton onClick={() => setIsDialogOpen(true)}>
|
settingTitle={t('library.settings.global_update.auto_update.interval.label.title')}
|
||||||
<ListItemText
|
settingValue={t('library.settings.global_update.auto_update.interval.label.value', {
|
||||||
primary={t('library.settings.global_update.auto_update.interval.label.title')}
|
hours: autoUpdateIntervalHours,
|
||||||
secondary={t('library.settings.global_update.auto_update.interval.label.value', {
|
})}
|
||||||
hours: autoUpdateIntervalHours,
|
value={autoUpdateIntervalHours}
|
||||||
})}
|
minValue={MIN_INTERVAL_HOURS}
|
||||||
secondaryTypographyProps={{ style: { display: 'flex', flexDirection: 'column' } }}
|
maxValue={MAX_INTERVAL_HOURS}
|
||||||
/>
|
defaultValue={DEFAULT_INTERVAL_HOURS}
|
||||||
</ListItemButton>
|
showSlider
|
||||||
|
dialogTitle={t('library.settings.global_update.auto_update.interval.label.title')}
|
||||||
<Dialog open={isDialogOpen} onClose={closeDialog}>
|
valueUnit={t('global.time.hour_short')}
|
||||||
<DialogContent>
|
handleUpdate={updateSetting}
|
||||||
<DialogTitle sx={{ paddingLeft: 0 }}>
|
/>
|
||||||
{t('library.settings.global_update.auto_update.interval.label.title')}
|
|
||||||
</DialogTitle>
|
|
||||||
<TextField
|
|
||||||
sx={{
|
|
||||||
width: '100%',
|
|
||||||
margin: 'auto',
|
|
||||||
}}
|
|
||||||
InputProps={{
|
|
||||||
inputProps: { min: MIN_INTERVAL_HOURS },
|
|
||||||
startAdornment: (
|
|
||||||
<InputAdornment position="start">{t('global.time.hour_short')}</InputAdornment>
|
|
||||||
),
|
|
||||||
}}
|
|
||||||
autoFocus
|
|
||||||
value={dialogUpdateIntervalHours}
|
|
||||||
type="number"
|
|
||||||
onChange={(e) => setDialogUpdateIntervalHours(Number(e.target.value))}
|
|
||||||
/>
|
|
||||||
</DialogContent>
|
|
||||||
<DialogActions>
|
|
||||||
<Button onClick={closeDialog} color="primary">
|
|
||||||
{t('global.button.cancel')}
|
|
||||||
</Button>
|
|
||||||
<Button
|
|
||||||
onClick={() => {
|
|
||||||
updateSetting(dialogUpdateIntervalHours);
|
|
||||||
}}
|
|
||||||
color="primary"
|
|
||||||
>
|
|
||||||
{t('global.button.ok')}
|
|
||||||
</Button>
|
|
||||||
</DialogActions>
|
|
||||||
</Dialog>
|
|
||||||
</>
|
|
||||||
) : null}
|
) : null}
|
||||||
</List>
|
</List>
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -157,6 +157,35 @@
|
|||||||
"queued": "Queued"
|
"queued": "Queued"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"settings": {
|
||||||
|
"file_type": {
|
||||||
|
"label": {
|
||||||
|
"cbz": "Save as CBZ archive"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"download_path": {
|
||||||
|
"label": {
|
||||||
|
"description": "The path to the directory on the server where downloaded files should get saved in",
|
||||||
|
"title": "Download location"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"auto_download": {
|
||||||
|
"label": {
|
||||||
|
"new_chapters": "Download new chapters",
|
||||||
|
"ignore_with_unread_chapters": "Ignore automatic chapter downloads for entries with unread chapters"
|
||||||
|
},
|
||||||
|
"title": "Auto-download"
|
||||||
|
},
|
||||||
|
"download_ahead": {
|
||||||
|
"label": {
|
||||||
|
"while_reading": "Auto download while reading",
|
||||||
|
"unread_chapters_to_download": "Number of unread chapters to download",
|
||||||
|
"value": "{{chapters}} $t(chapter.title)"
|
||||||
|
},
|
||||||
|
"title": "Download ahead"
|
||||||
|
},
|
||||||
|
"title": "Download settings"
|
||||||
|
},
|
||||||
"title": "Downloads"
|
"title": "Downloads"
|
||||||
},
|
},
|
||||||
"extension": {
|
"extension": {
|
||||||
|
|||||||
@@ -406,34 +406,54 @@ export const WEBUI_UPDATE_STATUS = gql`
|
|||||||
|
|
||||||
export const SERVER_SETTINGS = gql`
|
export const SERVER_SETTINGS = gql`
|
||||||
fragment SERVER_SETTINGS on SettingsType {
|
fragment SERVER_SETTINGS on SettingsType {
|
||||||
autoDownloadNewChapters
|
# Server ip and port bindings
|
||||||
backupInterval
|
|
||||||
backupPath
|
|
||||||
backupTTL
|
|
||||||
backupTime
|
|
||||||
basicAuthEnabled
|
|
||||||
basicAuthPassword
|
|
||||||
basicAuthUsername
|
|
||||||
debugLogsEnabled
|
|
||||||
downloadAsCbz
|
|
||||||
downloadsPath
|
|
||||||
electronPath
|
|
||||||
excludeCompleted
|
|
||||||
excludeNotStarted
|
|
||||||
excludeUnreadChapters
|
|
||||||
globalUpdateInterval
|
|
||||||
initialOpenInBrowserEnabled
|
|
||||||
ip
|
ip
|
||||||
localSourcePath
|
|
||||||
maxSourcesInParallel
|
|
||||||
port
|
port
|
||||||
|
|
||||||
|
# Socks proxy
|
||||||
socksProxyEnabled
|
socksProxyEnabled
|
||||||
socksProxyHost
|
socksProxyHost
|
||||||
socksProxyPort
|
socksProxyPort
|
||||||
systemTrayEnabled
|
|
||||||
webUIChannel
|
# webUI
|
||||||
webUIFlavor
|
webUIFlavor
|
||||||
|
initialOpenInBrowserEnabled
|
||||||
webUIInterface
|
webUIInterface
|
||||||
|
electronPath
|
||||||
|
webUIChannel
|
||||||
webUIUpdateCheckInterval
|
webUIUpdateCheckInterval
|
||||||
|
|
||||||
|
# downloader
|
||||||
|
downloadAsCbz
|
||||||
|
downloadsPath
|
||||||
|
autoDownloadNewChapters
|
||||||
|
excludeEntryWithUnreadChapters
|
||||||
|
autoDownloadAheadLimit
|
||||||
|
|
||||||
|
# requests
|
||||||
|
maxSourcesInParallel
|
||||||
|
|
||||||
|
# updater
|
||||||
|
excludeUnreadChapters
|
||||||
|
excludeNotStarted
|
||||||
|
excludeCompleted
|
||||||
|
globalUpdateInterval
|
||||||
|
updateMangas
|
||||||
|
|
||||||
|
# Authentication
|
||||||
|
basicAuthEnabled
|
||||||
|
basicAuthUsername
|
||||||
|
basicAuthPassword
|
||||||
|
|
||||||
|
# misc
|
||||||
|
debugLogsEnabled
|
||||||
|
gqlDebugLogsEnabled
|
||||||
|
systemTrayEnabled
|
||||||
|
|
||||||
|
# backup
|
||||||
|
backupPath
|
||||||
|
backupTime
|
||||||
|
backupInterval
|
||||||
|
backupTTL
|
||||||
}
|
}
|
||||||
`;
|
`;
|
||||||
|
|||||||
@@ -2108,7 +2108,7 @@ export type WebuiUpdateInfoFragment = { __typename?: 'WebUIUpdateInfo', channel:
|
|||||||
|
|
||||||
export type WebuiUpdateStatusFragment = { __typename?: 'WebUIUpdateStatus', progress: number, state: UpdateState, info: { __typename?: 'WebUIUpdateInfo', channel: string, tag: string, updateAvailable: boolean } };
|
export type WebuiUpdateStatusFragment = { __typename?: 'WebUIUpdateStatus', progress: number, state: UpdateState, info: { __typename?: 'WebUIUpdateInfo', channel: string, tag: string, updateAvailable: boolean } };
|
||||||
|
|
||||||
export type ServerSettingsFragment = { __typename?: 'SettingsType', autoDownloadNewChapters: boolean, backupInterval: number, backupPath: string, backupTTL: number, backupTime: string, basicAuthEnabled: boolean, basicAuthPassword: string, basicAuthUsername: string, debugLogsEnabled: boolean, downloadAsCbz: boolean, downloadsPath: string, electronPath: string, excludeCompleted: boolean, excludeNotStarted: boolean, excludeUnreadChapters: boolean, globalUpdateInterval: number, initialOpenInBrowserEnabled: boolean, ip: string, localSourcePath: string, maxSourcesInParallel: number, port: number, socksProxyEnabled: boolean, socksProxyHost: string, socksProxyPort: string, systemTrayEnabled: boolean, webUIChannel: WebUiChannel, webUIFlavor: WebUiFlavor, webUIInterface: WebUiInterface, webUIUpdateCheckInterval: number };
|
export type ServerSettingsFragment = { __typename?: 'SettingsType', ip: string, port: number, socksProxyEnabled: boolean, socksProxyHost: string, socksProxyPort: string, webUIFlavor: WebUiFlavor, initialOpenInBrowserEnabled: boolean, webUIInterface: WebUiInterface, electronPath: string, webUIChannel: WebUiChannel, webUIUpdateCheckInterval: number, downloadAsCbz: boolean, downloadsPath: string, autoDownloadNewChapters: boolean, excludeEntryWithUnreadChapters: boolean, autoDownloadAheadLimit: number, maxSourcesInParallel: number, excludeUnreadChapters: boolean, excludeNotStarted: boolean, excludeCompleted: boolean, globalUpdateInterval: number, updateMangas: boolean, basicAuthEnabled: boolean, basicAuthUsername: string, basicAuthPassword: string, debugLogsEnabled: boolean, gqlDebugLogsEnabled: boolean, systemTrayEnabled: boolean, backupPath: string, backupTime: string, backupInterval: number, backupTTL: number };
|
||||||
|
|
||||||
export type CreateBackupMutationVariables = Exact<{
|
export type CreateBackupMutationVariables = Exact<{
|
||||||
input: CreateBackupInput;
|
input: CreateBackupInput;
|
||||||
@@ -2388,14 +2388,14 @@ export type ResetServerSettingsMutationVariables = Exact<{
|
|||||||
}>;
|
}>;
|
||||||
|
|
||||||
|
|
||||||
export type ResetServerSettingsMutation = { __typename?: 'Mutation', resetSettings: { __typename?: 'ResetSettingsPayload', clientMutationId?: string | null, settings: { __typename?: 'SettingsType', autoDownloadNewChapters: boolean, backupInterval: number, backupPath: string, backupTTL: number, backupTime: string, basicAuthEnabled: boolean, basicAuthPassword: string, basicAuthUsername: string, debugLogsEnabled: boolean, downloadAsCbz: boolean, downloadsPath: string, electronPath: string, excludeCompleted: boolean, excludeNotStarted: boolean, excludeUnreadChapters: boolean, globalUpdateInterval: number, initialOpenInBrowserEnabled: boolean, ip: string, localSourcePath: string, maxSourcesInParallel: number, port: number, socksProxyEnabled: boolean, socksProxyHost: string, socksProxyPort: string, systemTrayEnabled: boolean, webUIChannel: WebUiChannel, webUIFlavor: WebUiFlavor, webUIInterface: WebUiInterface, webUIUpdateCheckInterval: number } } };
|
export type ResetServerSettingsMutation = { __typename?: 'Mutation', resetSettings: { __typename?: 'ResetSettingsPayload', clientMutationId?: string | null, settings: { __typename?: 'SettingsType', ip: string, port: number, socksProxyEnabled: boolean, socksProxyHost: string, socksProxyPort: string, webUIFlavor: WebUiFlavor, initialOpenInBrowserEnabled: boolean, webUIInterface: WebUiInterface, electronPath: string, webUIChannel: WebUiChannel, webUIUpdateCheckInterval: number, downloadAsCbz: boolean, downloadsPath: string, autoDownloadNewChapters: boolean, excludeEntryWithUnreadChapters: boolean, autoDownloadAheadLimit: number, maxSourcesInParallel: number, excludeUnreadChapters: boolean, excludeNotStarted: boolean, excludeCompleted: boolean, globalUpdateInterval: number, updateMangas: boolean, basicAuthEnabled: boolean, basicAuthUsername: string, basicAuthPassword: string, debugLogsEnabled: boolean, gqlDebugLogsEnabled: boolean, systemTrayEnabled: boolean, backupPath: string, backupTime: string, backupInterval: number, backupTTL: number } } };
|
||||||
|
|
||||||
export type UpdateServerSettingsMutationVariables = Exact<{
|
export type UpdateServerSettingsMutationVariables = Exact<{
|
||||||
input: SetSettingsInput;
|
input: SetSettingsInput;
|
||||||
}>;
|
}>;
|
||||||
|
|
||||||
|
|
||||||
export type UpdateServerSettingsMutation = { __typename?: 'Mutation', setSettings: { __typename?: 'SetSettingsPayload', clientMutationId?: string | null, settings: { __typename?: 'SettingsType', autoDownloadNewChapters: boolean, backupInterval: number, backupPath: string, backupTTL: number, backupTime: string, basicAuthEnabled: boolean, basicAuthPassword: string, basicAuthUsername: string, debugLogsEnabled: boolean, downloadAsCbz: boolean, downloadsPath: string, electronPath: string, excludeCompleted: boolean, excludeNotStarted: boolean, excludeUnreadChapters: boolean, globalUpdateInterval: number, initialOpenInBrowserEnabled: boolean, ip: string, localSourcePath: string, maxSourcesInParallel: number, port: number, socksProxyEnabled: boolean, socksProxyHost: string, socksProxyPort: string, systemTrayEnabled: boolean, webUIChannel: WebUiChannel, webUIFlavor: WebUiFlavor, webUIInterface: WebUiInterface, webUIUpdateCheckInterval: number } } };
|
export type UpdateServerSettingsMutation = { __typename?: 'Mutation', setSettings: { __typename?: 'SetSettingsPayload', clientMutationId?: string | null, settings: { __typename?: 'SettingsType', ip: string, port: number, socksProxyEnabled: boolean, socksProxyHost: string, socksProxyPort: string, webUIFlavor: WebUiFlavor, initialOpenInBrowserEnabled: boolean, webUIInterface: WebUiInterface, electronPath: string, webUIChannel: WebUiChannel, webUIUpdateCheckInterval: number, downloadAsCbz: boolean, downloadsPath: string, autoDownloadNewChapters: boolean, excludeEntryWithUnreadChapters: boolean, autoDownloadAheadLimit: number, maxSourcesInParallel: number, excludeUnreadChapters: boolean, excludeNotStarted: boolean, excludeCompleted: boolean, globalUpdateInterval: number, updateMangas: boolean, basicAuthEnabled: boolean, basicAuthUsername: string, basicAuthPassword: string, debugLogsEnabled: boolean, gqlDebugLogsEnabled: boolean, systemTrayEnabled: boolean, backupPath: string, backupTime: string, backupInterval: number, backupTTL: number } } };
|
||||||
|
|
||||||
export type GetSourceMangasFetchMutationVariables = Exact<{
|
export type GetSourceMangasFetchMutationVariables = Exact<{
|
||||||
input: FetchSourceMangaInput;
|
input: FetchSourceMangaInput;
|
||||||
@@ -2591,7 +2591,7 @@ export type GetWebuiUpdateStatusQuery = { __typename?: 'Query', getWebUIUpdateSt
|
|||||||
export type GetServerSettingsQueryVariables = Exact<{ [key: string]: never; }>;
|
export type GetServerSettingsQueryVariables = Exact<{ [key: string]: never; }>;
|
||||||
|
|
||||||
|
|
||||||
export type GetServerSettingsQuery = { __typename?: 'Query', settings: { __typename?: 'SettingsType', autoDownloadNewChapters: boolean, backupInterval: number, backupPath: string, backupTTL: number, backupTime: string, basicAuthEnabled: boolean, basicAuthPassword: string, basicAuthUsername: string, debugLogsEnabled: boolean, downloadAsCbz: boolean, downloadsPath: string, electronPath: string, excludeCompleted: boolean, excludeNotStarted: boolean, excludeUnreadChapters: boolean, globalUpdateInterval: number, initialOpenInBrowserEnabled: boolean, ip: string, localSourcePath: string, maxSourcesInParallel: number, port: number, socksProxyEnabled: boolean, socksProxyHost: string, socksProxyPort: string, systemTrayEnabled: boolean, webUIChannel: WebUiChannel, webUIFlavor: WebUiFlavor, webUIInterface: WebUiInterface, webUIUpdateCheckInterval: number } };
|
export type GetServerSettingsQuery = { __typename?: 'Query', settings: { __typename?: 'SettingsType', ip: string, port: number, socksProxyEnabled: boolean, socksProxyHost: string, socksProxyPort: string, webUIFlavor: WebUiFlavor, initialOpenInBrowserEnabled: boolean, webUIInterface: WebUiInterface, electronPath: string, webUIChannel: WebUiChannel, webUIUpdateCheckInterval: number, downloadAsCbz: boolean, downloadsPath: string, autoDownloadNewChapters: boolean, excludeEntryWithUnreadChapters: boolean, autoDownloadAheadLimit: number, maxSourcesInParallel: number, excludeUnreadChapters: boolean, excludeNotStarted: boolean, excludeCompleted: boolean, globalUpdateInterval: number, updateMangas: boolean, basicAuthEnabled: boolean, basicAuthUsername: string, basicAuthPassword: string, debugLogsEnabled: boolean, gqlDebugLogsEnabled: boolean, systemTrayEnabled: boolean, backupPath: string, backupTime: string, backupInterval: number, backupTTL: number } };
|
||||||
|
|
||||||
export type GetSourceQueryVariables = Exact<{
|
export type GetSourceQueryVariables = Exact<{
|
||||||
id: Scalars['LongString']['input'];
|
id: Scalars['LongString']['input'];
|
||||||
|
|||||||
@@ -6,7 +6,7 @@
|
|||||||
* file, You can obtain one at https://mozilla.org/MPL/2.0/.
|
* file, You can obtain one at https://mozilla.org/MPL/2.0/.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import { useContext, useEffect, useState } from 'react';
|
import { useContext, useEffect, useMemo, useState } from 'react';
|
||||||
import AutoStoriesIcon from '@mui/icons-material/AutoStories';
|
import AutoStoriesIcon from '@mui/icons-material/AutoStories';
|
||||||
import List from '@mui/material/List';
|
import List from '@mui/material/List';
|
||||||
import ListAltIcon from '@mui/icons-material/ListAlt';
|
import ListAltIcon from '@mui/icons-material/ListAlt';
|
||||||
@@ -29,18 +29,19 @@ import DialogContent from '@mui/material/DialogContent';
|
|||||||
import DialogContentText from '@mui/material/DialogContentText';
|
import DialogContentText from '@mui/material/DialogContentText';
|
||||||
import TextField from '@mui/material/TextField';
|
import TextField from '@mui/material/TextField';
|
||||||
import FavoriteIcon from '@mui/icons-material/Favorite';
|
import FavoriteIcon from '@mui/icons-material/Favorite';
|
||||||
import Slider from '@mui/material/Slider';
|
import { Link, MenuItem, Select } from '@mui/material';
|
||||||
import { DialogTitle, Link, ListItemButton, MenuItem, Select } from '@mui/material';
|
|
||||||
import ViewModuleIcon from '@mui/icons-material/ViewModule';
|
|
||||||
import { useTranslation } from 'react-i18next';
|
import { useTranslation } from 'react-i18next';
|
||||||
import LanguageIcon from '@mui/icons-material/Language';
|
import LanguageIcon from '@mui/icons-material/Language';
|
||||||
import CollectionsOutlinedBookmarkIcon from '@mui/icons-material/CollectionsBookmarkOutlined';
|
import CollectionsOutlinedBookmarkIcon from '@mui/icons-material/CollectionsBookmarkOutlined';
|
||||||
|
import GetAppOutlinedIcon from '@mui/icons-material/GetAppOutlined';
|
||||||
|
import ViewModuleIcon from '@mui/icons-material/ViewModule';
|
||||||
import { requestManager } from '@/lib/requests/RequestManager.ts';
|
import { requestManager } from '@/lib/requests/RequestManager.ts';
|
||||||
import { langCodeToName } from '@/util/language';
|
import { langCodeToName } from '@/util/language';
|
||||||
import { useLocalStorage } from '@/util/useLocalStorage';
|
import { useLocalStorage } from '@/util/useLocalStorage';
|
||||||
import { ListItemLink } from '@/components/util/ListItemLink';
|
import { ListItemLink } from '@/components/util/ListItemLink';
|
||||||
import { DarkTheme } from '@/components/context/DarkTheme';
|
import { DarkTheme } from '@/components/context/DarkTheme';
|
||||||
import { NavBarContext } from '@/components/context/NavbarContext.tsx';
|
import { NavBarContext } from '@/components/context/NavbarContext.tsx';
|
||||||
|
import { NumberSetting } from '@/components/settings/NumberSetting.tsx';
|
||||||
|
|
||||||
export function Settings() {
|
export function Settings() {
|
||||||
const { t, i18n } = useTranslation();
|
const { t, i18n } = useTranslation();
|
||||||
@@ -58,9 +59,9 @@ export function Settings() {
|
|||||||
const [dialogOpen, setDialogOpen] = useState(false);
|
const [dialogOpen, setDialogOpen] = useState(false);
|
||||||
const [dialogValue, setDialogValue] = useState(serverAddress);
|
const [dialogValue, setDialogValue] = useState(serverAddress);
|
||||||
|
|
||||||
const [dialogOpenItemWidth, setDialogOpenItemWidth] = useState(false);
|
const DEFAULT_ITEM_WIDTH = 300;
|
||||||
const [ItemWidth, setItemWidth] = useLocalStorage<number>('ItemWidth', 300);
|
const itemWidthIcon = useMemo(() => <ViewModuleIcon />, []);
|
||||||
const [DialogItemWidth, setDialogItemWidth] = useState(ItemWidth);
|
const [itemWidth, setItemWidth] = useLocalStorage<number>('ItemWidth', DEFAULT_ITEM_WIDTH);
|
||||||
|
|
||||||
const handleDialogOpen = () => {
|
const handleDialogOpen = () => {
|
||||||
setDialogValue(serverAddress);
|
setDialogValue(serverAddress);
|
||||||
@@ -78,29 +79,6 @@ export function Settings() {
|
|||||||
requestManager.updateClient({ baseURL: serverBaseUrl });
|
requestManager.updateClient({ baseURL: serverBaseUrl });
|
||||||
};
|
};
|
||||||
|
|
||||||
const handleDialogOpenItemWidth = () => {
|
|
||||||
setDialogItemWidth(ItemWidth);
|
|
||||||
setDialogOpenItemWidth(true);
|
|
||||||
};
|
|
||||||
|
|
||||||
const handleDialogCancelItemWidth = () => {
|
|
||||||
setDialogOpenItemWidth(false);
|
|
||||||
};
|
|
||||||
|
|
||||||
const handleDialogSubmitItemWidth = () => {
|
|
||||||
setDialogOpenItemWidth(false);
|
|
||||||
setItemWidth(DialogItemWidth);
|
|
||||||
};
|
|
||||||
|
|
||||||
const handleDialogResetItemWidth = () => {
|
|
||||||
setDialogOpenItemWidth(false);
|
|
||||||
setItemWidth(300);
|
|
||||||
};
|
|
||||||
|
|
||||||
const handleChange = (event: Event, newValue: number | number[]) => {
|
|
||||||
setDialogItemWidth(newValue as number);
|
|
||||||
};
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<List sx={{ padding: 0 }}>
|
<List sx={{ padding: 0 }}>
|
||||||
@@ -122,6 +100,12 @@ export function Settings() {
|
|||||||
</ListItemIcon>
|
</ListItemIcon>
|
||||||
<ListItemText primary={t('library.title')} />
|
<ListItemText primary={t('library.title')} />
|
||||||
</ListItemLink>
|
</ListItemLink>
|
||||||
|
<ListItemLink to="/settings/downloadSettings">
|
||||||
|
<ListItemIcon>
|
||||||
|
<GetAppOutlinedIcon />
|
||||||
|
</ListItemIcon>
|
||||||
|
<ListItemText primary={t('download.title')} />
|
||||||
|
</ListItemLink>
|
||||||
<ListItemLink to="/settings/backup">
|
<ListItemLink to="/settings/backup">
|
||||||
<ListItemIcon>
|
<ListItemIcon>
|
||||||
<BackupIcon />
|
<BackupIcon />
|
||||||
@@ -137,16 +121,20 @@ export function Settings() {
|
|||||||
<Switch edge="end" checked={darkTheme} onChange={() => setDarkTheme(!darkTheme)} />
|
<Switch edge="end" checked={darkTheme} onChange={() => setDarkTheme(!darkTheme)} />
|
||||||
</ListItemSecondaryAction>
|
</ListItemSecondaryAction>
|
||||||
</ListItem>
|
</ListItem>
|
||||||
<ListItemButton
|
<NumberSetting
|
||||||
onClick={() => {
|
settingTitle={t('settings.label.manga_item_width')}
|
||||||
handleDialogOpenItemWidth();
|
settingValue={`px:${itemWidth}`}
|
||||||
}}
|
settingIcon={itemWidthIcon}
|
||||||
>
|
value={itemWidth}
|
||||||
<ListItemIcon>
|
defaultValue={DEFAULT_ITEM_WIDTH}
|
||||||
<ViewModuleIcon />
|
minValue={100}
|
||||||
</ListItemIcon>
|
maxValue={1000}
|
||||||
<ListItemText primary={t('settings.label.manga_item_width')} secondary={`px:${ItemWidth}`} />
|
stepSize={10}
|
||||||
</ListItemButton>
|
dialogTitle={t('settings.label.manga_item_width')}
|
||||||
|
valueUnit="px"
|
||||||
|
showSlider
|
||||||
|
handleUpdate={setItemWidth}
|
||||||
|
/>
|
||||||
<ListItem>
|
<ListItem>
|
||||||
<ListItemIcon>
|
<ListItemIcon>
|
||||||
<FavoriteIcon />
|
<FavoriteIcon />
|
||||||
@@ -248,47 +236,6 @@ export function Settings() {
|
|||||||
</Button>
|
</Button>
|
||||||
</DialogActions>
|
</DialogActions>
|
||||||
</Dialog>
|
</Dialog>
|
||||||
|
|
||||||
<Dialog open={dialogOpenItemWidth} onClose={handleDialogCancelItemWidth}>
|
|
||||||
<DialogTitle>{t('settings.label.manga_item_width')}</DialogTitle>
|
|
||||||
<DialogContent
|
|
||||||
sx={{
|
|
||||||
width: '98%',
|
|
||||||
margin: 'auto',
|
|
||||||
}}
|
|
||||||
>
|
|
||||||
<TextField
|
|
||||||
sx={{
|
|
||||||
width: '100%',
|
|
||||||
margin: 'auto',
|
|
||||||
}}
|
|
||||||
autoFocus
|
|
||||||
value={DialogItemWidth}
|
|
||||||
type="number"
|
|
||||||
onChange={(e) => setDialogItemWidth(parseInt(e.target.value, 10))}
|
|
||||||
/>
|
|
||||||
<Slider
|
|
||||||
aria-label="Manga Item width"
|
|
||||||
defaultValue={300}
|
|
||||||
value={DialogItemWidth}
|
|
||||||
step={10}
|
|
||||||
min={100}
|
|
||||||
max={1000}
|
|
||||||
onChange={handleChange}
|
|
||||||
/>
|
|
||||||
</DialogContent>
|
|
||||||
<DialogActions>
|
|
||||||
<Button onClick={handleDialogResetItemWidth} color="primary">
|
|
||||||
{t('global.button.reset_to_default')}
|
|
||||||
</Button>
|
|
||||||
<Button onClick={handleDialogCancelItemWidth} color="primary">
|
|
||||||
{t('global.button.cancel')}
|
|
||||||
</Button>
|
|
||||||
<Button onClick={handleDialogSubmitItemWidth} color="primary">
|
|
||||||
{t('global.button.ok')}
|
|
||||||
</Button>
|
|
||||||
</DialogActions>
|
|
||||||
</Dialog>
|
|
||||||
</>
|
</>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
121
src/screens/settings/DownloadSettings.tsx
Normal file
121
src/screens/settings/DownloadSettings.tsx
Normal file
@@ -0,0 +1,121 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (C) Contributors to the Suwayomi project
|
||||||
|
*
|
||||||
|
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||||
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||||
|
* file, You can obtain one at https://mozilla.org/MPL/2.0/.
|
||||||
|
*/
|
||||||
|
|
||||||
|
import { useTranslation } from 'react-i18next';
|
||||||
|
import { useContext, useEffect } from 'react';
|
||||||
|
import List from '@mui/material/List';
|
||||||
|
import { ListItem, ListItemText, Switch } from '@mui/material';
|
||||||
|
import ListItemSecondaryAction from '@mui/material/ListItemSecondaryAction';
|
||||||
|
import ListSubheader from '@mui/material/ListSubheader';
|
||||||
|
import { ServerDirSetting } from '@/components/settings/ServerDirSetting';
|
||||||
|
import { NavBarContext, useSetDefaultBackTo } from '@/components/context/NavbarContext.tsx';
|
||||||
|
import { ServerSettings } from '@/typings.ts';
|
||||||
|
import { requestManager } from '@/lib/requests/RequestManager.ts';
|
||||||
|
import { DownloadAheadSetting } from '@/components/settings/downloads/DownloadAheadSetting.tsx';
|
||||||
|
|
||||||
|
type DownloadSettingsType = Pick<
|
||||||
|
ServerSettings,
|
||||||
|
| 'downloadAsCbz'
|
||||||
|
| 'downloadsPath'
|
||||||
|
| 'autoDownloadNewChapters'
|
||||||
|
| 'autoDownloadAheadLimit'
|
||||||
|
| 'excludeEntryWithUnreadChapters'
|
||||||
|
>;
|
||||||
|
|
||||||
|
const extractDownloadSettings = (settings: ServerSettings): DownloadSettingsType => ({
|
||||||
|
downloadAsCbz: settings.downloadAsCbz,
|
||||||
|
downloadsPath: settings.downloadsPath,
|
||||||
|
autoDownloadNewChapters: settings.autoDownloadNewChapters,
|
||||||
|
autoDownloadAheadLimit: settings.autoDownloadAheadLimit,
|
||||||
|
excludeEntryWithUnreadChapters: settings.excludeEntryWithUnreadChapters,
|
||||||
|
});
|
||||||
|
|
||||||
|
export const DownloadSettings = () => {
|
||||||
|
const { t } = useTranslation();
|
||||||
|
const { setTitle, setAction } = useContext(NavBarContext);
|
||||||
|
|
||||||
|
useSetDefaultBackTo('settings');
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
setTitle(t('download.settings.title'));
|
||||||
|
setAction(null);
|
||||||
|
}, [t]);
|
||||||
|
|
||||||
|
const { data } = requestManager.useGetServerSettings();
|
||||||
|
const downloadSettings = data ? extractDownloadSettings(data.settings) : undefined;
|
||||||
|
const [mutateSettings] = requestManager.useUpdateServerSettings();
|
||||||
|
|
||||||
|
const updateSetting = <Setting extends keyof DownloadSettingsType>(
|
||||||
|
setting: Setting,
|
||||||
|
value: DownloadSettingsType[Setting],
|
||||||
|
) => {
|
||||||
|
mutateSettings({ variables: { input: { settings: { [setting]: value } } } });
|
||||||
|
};
|
||||||
|
|
||||||
|
return (
|
||||||
|
<List>
|
||||||
|
<ServerDirSetting
|
||||||
|
settingName={t('download.settings.download_path.label.title')}
|
||||||
|
dialogDescription={t('download.settings.download_path.label.description')}
|
||||||
|
dirPath={downloadSettings?.downloadsPath}
|
||||||
|
handlePathChange={(path) => updateSetting('downloadsPath', path)}
|
||||||
|
/>
|
||||||
|
<ListItem>
|
||||||
|
<ListItemText primary={t('download.settings.file_type.label.cbz')} />
|
||||||
|
<ListItemSecondaryAction>
|
||||||
|
<Switch
|
||||||
|
edge="end"
|
||||||
|
checked={!!downloadSettings?.downloadAsCbz}
|
||||||
|
onChange={(e) => updateSetting('downloadAsCbz', e.target.checked)}
|
||||||
|
/>
|
||||||
|
</ListItemSecondaryAction>
|
||||||
|
</ListItem>
|
||||||
|
<List
|
||||||
|
subheader={
|
||||||
|
<ListSubheader component="div" id="download-settings-auto-download">
|
||||||
|
{t('download.settings.auto_download.title')}
|
||||||
|
</ListSubheader>
|
||||||
|
}
|
||||||
|
>
|
||||||
|
<ListItem>
|
||||||
|
<ListItemText primary={t('download.settings.auto_download.label.new_chapters')} />
|
||||||
|
<ListItemSecondaryAction>
|
||||||
|
<Switch
|
||||||
|
edge="end"
|
||||||
|
checked={!!downloadSettings?.autoDownloadNewChapters}
|
||||||
|
onChange={(e) => updateSetting('autoDownloadNewChapters', e.target.checked)}
|
||||||
|
/>
|
||||||
|
</ListItemSecondaryAction>
|
||||||
|
</ListItem>
|
||||||
|
{downloadSettings?.autoDownloadNewChapters ? (
|
||||||
|
<ListItem>
|
||||||
|
<ListItemText
|
||||||
|
primary={t('download.settings.auto_download.label.ignore_with_unread_chapters')}
|
||||||
|
/>
|
||||||
|
<ListItemSecondaryAction>
|
||||||
|
<Switch
|
||||||
|
edge="end"
|
||||||
|
checked={downloadSettings.excludeEntryWithUnreadChapters}
|
||||||
|
onChange={(e) => updateSetting('excludeEntryWithUnreadChapters', e.target.checked)}
|
||||||
|
/>
|
||||||
|
</ListItemSecondaryAction>
|
||||||
|
</ListItem>
|
||||||
|
) : null}
|
||||||
|
</List>
|
||||||
|
<List
|
||||||
|
subheader={
|
||||||
|
<ListSubheader component="div" id="download-settings-download-ahead">
|
||||||
|
{t('download.settings.download_ahead.title')}
|
||||||
|
</ListSubheader>
|
||||||
|
}
|
||||||
|
>
|
||||||
|
<DownloadAheadSetting />
|
||||||
|
</List>
|
||||||
|
</List>
|
||||||
|
);
|
||||||
|
};
|
||||||
Reference in New Issue
Block a user