diff --git a/web/src/components/Settings/PrimarySettingsComponent.jsx b/web/src/components/Settings/PrimarySettingsComponent.jsx
new file mode 100644
index 0000000..4c51482
--- /dev/null
+++ b/web/src/components/Settings/PrimarySettingsComponent.jsx
@@ -0,0 +1,166 @@
+import { useTranslation } from 'react-i18next'
+import { USBIcon, RAMIcon } from 'icons'
+import { FormControlLabel, Switch } from '@material-ui/core'
+import TextField from '@material-ui/core/TextField'
+
+import {
+ Divider,
+ PreloadCacheValue,
+ MainSettingsContent,
+ StorageButton,
+ StorageIconWrapper,
+ CacheStorageSelector,
+ SettingSectionLabel,
+ PreloadCachePercentage,
+ cacheBeforeReaderColor,
+ cacheAfterReaderColor,
+} from './style'
+import SliderInput from './SliderInput'
+
+const CacheStorageLocationLabel = ({ style }) => {
+ const { t } = useTranslation()
+
+ return (
+
+ {t('SettingsDialog.CacheStorageLocation')}
+ {t('SettingsDialog.UseDiskDesc')}
+
+ )
+}
+
+export default function PrimarySettingsComponent({
+ settings,
+ inputForm,
+ cachePercentage,
+ cacheSize,
+ isProMode,
+ setCacheSize,
+ setCachePercentage,
+ updateSettings,
+}) {
+ const { t } = useTranslation()
+ const { PreloadBuffer, UseDisk, TorrentsSavePath, RemoveCacheOnDrop } = settings || {}
+
+ return (
+
+
+
{t('SettingsDialog.CacheSettings')}
+
+
+
+
+
+ {100 - cachePercentage}% ({Math.round((cacheSize / 100) * (100 - cachePercentage))} MB)
+
+
+ {t('SettingsDialog.CacheBeforeReaderDesc')}
+
+
+
+
+ {cachePercentage}% ({Math.round((cacheSize / 100) * cachePercentage)} MB)
+
+
+ {t('SettingsDialog.CacheAfterReaderDesc')}
+
+
+
+
+
setCacheSize(Math.round(value / 8) * 8)}
+ />
+
+
+
+ }
+ label={t('SettingsDialog.PreloadBuffer')}
+ />
+
+
+ {UseDisk ? (
+
+
+
+
+
updateSettings({ UseDisk: false })}>
+
+
+
+
+ {t('SettingsDialog.RAM')}
+
+
+
+
+
+
+
+ {t('SettingsDialog.Disk')}
+
+
+
+
}
+ label={t('SettingsDialog.RemoveCacheOnDrop')}
+ />
+
+ {t('SettingsDialog.RemoveCacheOnDropDesc')}
+
+
+
+
+ ) : (
+
+
+
+
+
+
+
+
+ {t('SettingsDialog.RAM')}
+
+
+ updateSettings({ UseDisk: true })}>
+
+
+
+
+ {t('SettingsDialog.Disk')}
+
+
+ )}
+
+ )
+}
diff --git a/web/src/components/Settings/SecondarySettingsComponent.jsx b/web/src/components/Settings/SecondarySettingsComponent.jsx
new file mode 100644
index 0000000..0d1fcd6
--- /dev/null
+++ b/web/src/components/Settings/SecondarySettingsComponent.jsx
@@ -0,0 +1,142 @@
+import { useTranslation } from 'react-i18next'
+import TextField from '@material-ui/core/TextField'
+import { FormControlLabel, InputLabel, Select, Switch } from '@material-ui/core'
+
+import { SecondarySettingsContent, SettingSectionLabel } from './style'
+
+export default function SecondarySettingsComponent({ settings, inputForm }) {
+ const { t } = useTranslation()
+
+ const {
+ RetrackersMode,
+ TorrentDisconnectTimeout,
+ EnableIPv6,
+ ForceEncrypt,
+ DisableTCP,
+ DisableUTP,
+ DisableUPNP,
+ DisableDHT,
+ DisablePEX,
+ DisableUpload,
+ DownloadRateLimit,
+ UploadRateLimit,
+ ConnectionsLimit,
+ DhtConnectionLimit,
+ PeersListenPort,
+ } = settings || {}
+
+ return (
+
+ {t('SettingsDialog.AdditionalSettings')}
+
+ }
+ label='IPv6'
+ />
+
+ }
+ label='TCP (Transmission Control Protocol)'
+ />
+
+ }
+ label='μTP (Micro Transport Protocol)'
+ />
+
+ }
+ label='PEX (Peer Exchange)'
+ />
+
+ }
+ label={t('SettingsDialog.ForceEncrypt')}
+ />
+
+
+
+
+
+ }
+ label={t('SettingsDialog.DHT')}
+ />
+
+
+
+
+
+ }
+ label={t('SettingsDialog.Upload')}
+ />
+
+
+
+
+
+ }
+ label='UPnP (Universal Plug and Play)'
+ />
+
+ {t('SettingsDialog.RetrackersMode')}
+
+
+
+ )
+}
diff --git a/web/src/components/Settings/SettingsDialog.jsx b/web/src/components/Settings/SettingsDialog.jsx
index b467880..fdbcbe2 100644
--- a/web/src/components/Settings/SettingsDialog.jsx
+++ b/web/src/components/Settings/SettingsDialog.jsx
@@ -1,19 +1,8 @@
import axios from 'axios'
import Dialog from '@material-ui/core/Dialog'
-import TextField from '@material-ui/core/TextField'
import Button from '@material-ui/core/Button'
import Checkbox from '@material-ui/core/Checkbox'
-import {
- FormControlLabel,
- Grid,
- Input,
- InputLabel,
- Select,
- Slider,
- Switch,
- useMediaQuery,
- useTheme,
-} from '@material-ui/core'
+import { FormControlLabel, useMediaQuery, useTheme } from '@material-ui/core'
import { settingsHost } from 'utils/Hosts'
import { useEffect, useState } from 'react'
import { useTranslation } from 'react-i18next'
@@ -22,85 +11,13 @@ import AppBar from '@material-ui/core/AppBar'
import Tabs from '@material-ui/core/Tabs'
import Tab from '@material-ui/core/Tab'
import SwipeableViews from 'react-swipeable-views'
-import { USBIcon, RAMIcon } from 'icons'
import CircularProgress from '@material-ui/core/CircularProgress'
-import {
- FooterSection,
- Divider,
- PreloadCacheValue,
- MainSettingsContent,
- SecondarySettingsContent,
- StorageButton,
- StorageIconWrapper,
- CacheStorageSelector,
- SettingSectionLabel,
- PreloadCachePercentage,
- cacheBeforeReaderColor,
- cacheAfterReaderColor,
- Content,
-} from './style'
+import { FooterSection, Content } from './style'
import defaultSettings from './defaultSettings'
import { a11yProps, TabPanel } from './tabComponents'
-
-const CacheStorageLocationLabel = ({ style }) => {
- const { t } = useTranslation()
-
- return (
-
- {t('SettingsDialog.CacheStorageLocation')}
- {t('SettingsDialog.UseDiskDesc')}
-
- )
-}
-
-const SliderInput = ({
- isProMode,
- title,
- value,
- setValue,
- sliderMin,
- sliderMax,
- inputMin,
- inputMax,
- step = 1,
- onBlurCallback,
-}) => {
- const onBlur = ({ target: { value } }) => {
- if (value < inputMin) return setValue(inputMin)
- if (value > inputMax) return setValue(inputMax)
-
- onBlurCallback && onBlurCallback(value)
- }
-
- const onInputChange = ({ target: { value } }) => setValue(value === '' ? '' : Number(value))
- const onSliderChange = (_, newValue) => setValue(newValue)
-
- return (
- <>
-
{title}
-
-
-
-
-
-
- {isProMode && (
-
-
-
- )}
-
- >
- )
-}
+import PrimarySettingsComponent from './PrimarySettingsComponent'
+import SecondarySettingsComponent from './SecondarySettingsComponent'
export default function SettingsDialog({ handleClose }) {
const { t } = useTranslation()
@@ -149,29 +66,7 @@ export default function SettingsDialog({ handleClose }) {
setSettings(sets)
}
- const {
- CacheSize,
- PreloadBuffer,
- ReaderReadAHead,
- RetrackersMode,
- TorrentDisconnectTimeout,
- EnableIPv6,
- ForceEncrypt,
- DisableTCP,
- DisableUTP,
- DisableUPNP,
- DisableDHT,
- DisablePEX,
- DisableUpload,
- DownloadRateLimit,
- UploadRateLimit,
- ConnectionsLimit,
- DhtConnectionLimit,
- PeersListenPort,
- UseDisk,
- TorrentsSavePath,
- RemoveCacheOnDrop,
- } = settings || {}
+ const { CacheSize, ReaderReadAHead } = settings || {}
useEffect(() => {
if (!CacheSize || !ReaderReadAHead) return
@@ -215,252 +110,20 @@ export default function SettingsDialog({ handleClose }) {
onChangeIndex={handleChangeIndex}
>
-
-
-
{t('SettingsDialog.CacheSettings')}
-
-
-
-
-
- {100 - cachePercentage}% ({Math.round((cacheSize / 100) * (100 - cachePercentage))} MB)
-
-
- {t('SettingsDialog.CacheBeforeReaderDesc')}
-
-
-
-
- {cachePercentage}% ({Math.round((cacheSize / 100) * cachePercentage)} MB)
-
-
- {t('SettingsDialog.CacheAfterReaderDesc')}
-
-
-
-
-
setCacheSize(Math.round(value / 8) * 8)}
- />
-
-
-
-
- }
- label={t('SettingsDialog.PreloadBuffer')}
- />
-
-
- {UseDisk ? (
-
-
-
-
-
updateSettings({ UseDisk: false })}>
-
-
-
-
- {t('SettingsDialog.RAM')}
-
-
-
-
-
-
-
- {t('SettingsDialog.Disk')}
-
-
-
-
- }
- label={t('SettingsDialog.RemoveCacheOnDrop')}
- />
-
- {t('SettingsDialog.RemoveCacheOnDropDesc')}
-
-
-
-
- ) : (
-
-
-
-
-
-
-
-
- {t('SettingsDialog.RAM')}
-
-
- updateSettings({ UseDisk: true })}>
-
-
-
-
- {t('SettingsDialog.Disk')}
-
-
- )}
-
+
-
- {t('SettingsDialog.AdditionalSettings')}
-
- }
- label='IPv6'
- />
-
- }
- label='TCP (Transmission Control Protocol)'
- />
-
- }
- label='μTP (Micro Transport Protocol)'
- />
-
- }
- label='PEX (Peer Exchange)'
- />
-
- }
- label={t('SettingsDialog.ForceEncrypt')}
- />
-
-
-
-
-
- }
- label={t('SettingsDialog.DHT')}
- />
-
-
-
-
-
-
- }
- label={t('SettingsDialog.Upload')}
- />
-
-
-
-
-
- }
- label='UPnP (Universal Plug and Play)'
- />
-
- {t('SettingsDialog.RetrackersMode')}
-
-
-
+
>
diff --git a/web/src/components/Settings/SliderInput.jsx b/web/src/components/Settings/SliderInput.jsx
new file mode 100644
index 0000000..a4d987e
--- /dev/null
+++ b/web/src/components/Settings/SliderInput.jsx
@@ -0,0 +1,49 @@
+import { Grid, Input, Slider } from '@material-ui/core'
+
+export default function SliderInput({
+ isProMode,
+ title,
+ value,
+ setValue,
+ sliderMin,
+ sliderMax,
+ inputMin,
+ inputMax,
+ step = 1,
+ onBlurCallback,
+}) {
+ const onBlur = ({ target: { value } }) => {
+ if (value < inputMin) return setValue(inputMin)
+ if (value > inputMax) return setValue(inputMax)
+
+ onBlurCallback && onBlurCallback(value)
+ }
+
+ const onInputChange = ({ target: { value } }) => setValue(value === '' ? '' : Number(value))
+ const onSliderChange = (_, newValue) => setValue(newValue)
+
+ return (
+ <>
+ {title}
+
+
+
+
+
+
+ {isProMode && (
+
+
+
+ )}
+
+ >
+ )
+}