mirror of
https://github.com/Ernous/TorrServerJellyfin.git
synced 2025-12-19 21:46:11 +05:00
refactor
This commit is contained in:
@@ -7,7 +7,6 @@ import AddDialogButton from 'components/Add'
|
|||||||
import RemoveAll from 'components/RemoveAll'
|
import RemoveAll from 'components/RemoveAll'
|
||||||
import SettingsDialog from 'components/Settings'
|
import SettingsDialog from 'components/Settings'
|
||||||
import AboutDialog from 'components/About'
|
import AboutDialog from 'components/About'
|
||||||
import UploadDialog from 'components/Upload'
|
|
||||||
import { CreditCard as CreditCardIcon, List as ListIcon, Language as LanguageIcon } from '@material-ui/icons'
|
import { CreditCard as CreditCardIcon, List as ListIcon, Language as LanguageIcon } from '@material-ui/icons'
|
||||||
import List from '@material-ui/core/List'
|
import List from '@material-ui/core/List'
|
||||||
import CloseServer from 'components/CloseServer'
|
import CloseServer from 'components/CloseServer'
|
||||||
@@ -24,7 +23,6 @@ export default function Sidebar({ isDrawerOpen, setIsDonationDialogOpen }) {
|
|||||||
<AppSidebarStyle isDrawerOpen={isDrawerOpen}>
|
<AppSidebarStyle isDrawerOpen={isDrawerOpen}>
|
||||||
<List>
|
<List>
|
||||||
<AddDialogButton />
|
<AddDialogButton />
|
||||||
<UploadDialog />
|
|
||||||
<RemoveAll />
|
<RemoveAll />
|
||||||
<ListItem button component='a' target='_blank' href={playlistAllHost()}>
|
<ListItem button component='a' target='_blank' href={playlistAllHost()}>
|
||||||
<ListItemIcon>
|
<ListItemIcon>
|
||||||
|
|||||||
@@ -1,14 +1,10 @@
|
|||||||
import { useCallback, useMemo, useState } from 'react'
|
import { useMemo, useState } from 'react'
|
||||||
import Button from '@material-ui/core/Button'
|
import Button from '@material-ui/core/Button'
|
||||||
import TextField from '@material-ui/core/TextField'
|
import TextField from '@material-ui/core/TextField'
|
||||||
import Dialog from '@material-ui/core/Dialog'
|
import Dialog from '@material-ui/core/Dialog'
|
||||||
import DialogActions from '@material-ui/core/DialogActions'
|
|
||||||
import DialogContent from '@material-ui/core/DialogContent'
|
|
||||||
import DialogTitle from '@material-ui/core/DialogTitle'
|
|
||||||
import { torrentsHost, torrentUploadHost } from 'utils/Hosts'
|
import { torrentsHost, torrentUploadHost } from 'utils/Hosts'
|
||||||
import axios from 'axios'
|
import axios from 'axios'
|
||||||
import { useTranslation } from 'react-i18next'
|
import { useTranslation } from 'react-i18next'
|
||||||
import { Input, ListItem, ListItemIcon, ListItemText } from '@material-ui/core'
|
|
||||||
import styled, { css } from 'styled-components'
|
import styled, { css } from 'styled-components'
|
||||||
import { NoImageIcon, AddItemIcon, TorrentIcon } from 'icons'
|
import { NoImageIcon, AddItemIcon, TorrentIcon } from 'icons'
|
||||||
import debounce from 'lodash/debounce'
|
import debounce from 'lodash/debounce'
|
||||||
@@ -16,8 +12,7 @@ import { v4 as uuidv4 } from 'uuid'
|
|||||||
import useChangeLanguage from 'utils/useChangeLanguage'
|
import useChangeLanguage from 'utils/useChangeLanguage'
|
||||||
import { Cancel as CancelIcon } from '@material-ui/icons'
|
import { Cancel as CancelIcon } from '@material-ui/icons'
|
||||||
|
|
||||||
const AddDialogStyle = styled.div``
|
const Header = styled.div`
|
||||||
const TitleSection = styled.div`
|
|
||||||
background: #00a572;
|
background: #00a572;
|
||||||
color: rgba(0, 0, 0, 0.87);
|
color: rgba(0, 0, 0, 0.87);
|
||||||
font-size: 20px;
|
font-size: 20px;
|
||||||
@@ -27,14 +22,14 @@ const TitleSection = styled.div`
|
|||||||
padding: 15px 24px;
|
padding: 15px 24px;
|
||||||
position: relative;
|
position: relative;
|
||||||
`
|
`
|
||||||
const MainSection = styled.div`
|
const ContentWrapper = styled.div`
|
||||||
background: linear-gradient(145deg, #e4f6ed, #b5dec9);
|
background: linear-gradient(145deg, #e4f6ed, #b5dec9);
|
||||||
display: flex;
|
display: flex;
|
||||||
flex-direction: column;
|
flex-direction: column;
|
||||||
justify-content: space-between;
|
justify-content: space-between;
|
||||||
`
|
`
|
||||||
|
|
||||||
const MainSectionContentWrapper = styled.div`
|
const Content = styled.div`
|
||||||
flex: 1;
|
flex: 1;
|
||||||
display: grid;
|
display: grid;
|
||||||
grid-template-columns: repeat(2, 1fr);
|
grid-template-columns: repeat(2, 1fr);
|
||||||
@@ -110,6 +105,7 @@ const IconWrapper = styled.div`
|
|||||||
|
|
||||||
const FileUploadLabel = styled.label`
|
const FileUploadLabel = styled.label`
|
||||||
transition: all 0.3s;
|
transition: all 0.3s;
|
||||||
|
flex: 1;
|
||||||
`
|
`
|
||||||
|
|
||||||
const RightSideTopSection = styled.div`
|
const RightSideTopSection = styled.div`
|
||||||
@@ -290,6 +286,7 @@ export default function AddDialog({ handleClose }) {
|
|||||||
const data = new FormData()
|
const data = new FormData()
|
||||||
data.append('save', 'true')
|
data.append('save', 'true')
|
||||||
data.append('file', selectedFile)
|
data.append('file', selectedFile)
|
||||||
|
title && data.append('title', title)
|
||||||
posterUrl && data.append('poster', posterUrl)
|
posterUrl && data.append('poster', posterUrl)
|
||||||
axios.post(torrentUploadHost(), data).finally(() => handleClose())
|
axios.post(torrentUploadHost(), data).finally(() => handleClose())
|
||||||
} else {
|
} else {
|
||||||
@@ -307,8 +304,7 @@ export default function AddDialog({ handleClose }) {
|
|||||||
setTorrentSource(file.name)
|
setTorrentSource(file.name)
|
||||||
}
|
}
|
||||||
|
|
||||||
const clearSelectedFile = e => {
|
const clearSelectedFile = () => {
|
||||||
e.stopPropagation()
|
|
||||||
setSelectedFile()
|
setSelectedFile()
|
||||||
setTorrentSource('')
|
setTorrentSource('')
|
||||||
}
|
}
|
||||||
@@ -320,12 +316,11 @@ export default function AddDialog({ handleClose }) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
|
||||||
<Dialog open onClose={handleClose} aria-labelledby='form-dialog-title' fullWidth maxWidth='md'>
|
<Dialog open onClose={handleClose} aria-labelledby='form-dialog-title' fullWidth maxWidth='md'>
|
||||||
<AddDialogStyle>
|
<Header>{t('AddNewTorrent')}</Header>
|
||||||
<TitleSection>Add new torrent</TitleSection>
|
|
||||||
<MainSection>
|
<ContentWrapper>
|
||||||
<MainSectionContentWrapper>
|
<Content>
|
||||||
<LeftSide>
|
<LeftSide>
|
||||||
<TextField
|
<TextField
|
||||||
onChange={handleTitleChange}
|
onChange={handleTitleChange}
|
||||||
@@ -368,7 +363,7 @@ export default function AddDialog({ handleClose }) {
|
|||||||
size='small'
|
size='small'
|
||||||
disabled={!posterUrl}
|
disabled={!posterUrl}
|
||||||
>
|
>
|
||||||
Clear
|
{t('Clear')}
|
||||||
</Button>
|
</Button>
|
||||||
</PosterWrapper>
|
</PosterWrapper>
|
||||||
</LeftSide>
|
</LeftSide>
|
||||||
@@ -380,13 +375,13 @@ export default function AddDialog({ handleClose }) {
|
|||||||
value={torrentSource}
|
value={torrentSource}
|
||||||
margin='dense'
|
margin='dense'
|
||||||
label={t('TorrentSourceLink')}
|
label={t('TorrentSourceLink')}
|
||||||
helperText='magnet / hash / .torrent file link'
|
helperText={t('TorrentSourceOptions')}
|
||||||
type='text'
|
type='text'
|
||||||
fullWidth
|
fullWidth
|
||||||
onFocus={() => setTorrentSourceSelected(true)}
|
onFocus={() => setTorrentSourceSelected(true)}
|
||||||
onBlur={() => setTorrentSourceSelected(false)}
|
onBlur={() => setTorrentSourceSelected(false)}
|
||||||
inputProps={{ autoComplete: 'off' }}
|
inputProps={{ autoComplete: 'off' }}
|
||||||
disabled={selectedFile}
|
disabled={!!selectedFile}
|
||||||
/>
|
/>
|
||||||
</RightSideTopSection>
|
</RightSideTopSection>
|
||||||
|
|
||||||
@@ -401,7 +396,7 @@ export default function AddDialog({ handleClose }) {
|
|||||||
</TorrentIconWrapper>
|
</TorrentIconWrapper>
|
||||||
</RightSideBottomSectionFileSelected>
|
</RightSideBottomSectionFileSelected>
|
||||||
) : (
|
) : (
|
||||||
<FileUploadLabel htmlFor='upload-file' style={{ flex: 1 }}>
|
<FileUploadLabel htmlFor='upload-file'>
|
||||||
<input
|
<input
|
||||||
onChange={handleCapture}
|
onChange={handleCapture}
|
||||||
accept='.torrent'
|
accept='.torrent'
|
||||||
@@ -411,17 +406,18 @@ export default function AddDialog({ handleClose }) {
|
|||||||
/>
|
/>
|
||||||
|
|
||||||
<RightSideBottomSectionNoFile selectedFile={selectedFile} type='submit'>
|
<RightSideBottomSectionNoFile selectedFile={selectedFile} type='submit'>
|
||||||
<div>OR</div>
|
<div>{t('AppendFile.Or')}</div>
|
||||||
|
|
||||||
<IconWrapper>
|
<IconWrapper>
|
||||||
<AddItemIcon color='primary' />
|
<AddItemIcon color='primary' />
|
||||||
<div>CLICK / DRAG & DROP</div>
|
<div>{t('AppendFile.ClickOrDrag')}</div>
|
||||||
</IconWrapper>
|
</IconWrapper>
|
||||||
</RightSideBottomSectionNoFile>
|
</RightSideBottomSectionNoFile>
|
||||||
</FileUploadLabel>
|
</FileUploadLabel>
|
||||||
)}
|
)}
|
||||||
</RightSide>
|
</RightSide>
|
||||||
</MainSectionContentWrapper>
|
</Content>
|
||||||
|
|
||||||
<ButtonWrapper>
|
<ButtonWrapper>
|
||||||
<Button onClick={handleClose} color='primary' variant='outlined'>
|
<Button onClick={handleClose} color='primary' variant='outlined'>
|
||||||
{t('Cancel')}
|
{t('Cancel')}
|
||||||
@@ -431,52 +427,7 @@ export default function AddDialog({ handleClose }) {
|
|||||||
{t('Add')}
|
{t('Add')}
|
||||||
</Button>
|
</Button>
|
||||||
</ButtonWrapper>
|
</ButtonWrapper>
|
||||||
</MainSection>
|
</ContentWrapper>
|
||||||
</AddDialogStyle>
|
|
||||||
{/* <DialogTitle id='form-dialog-title'>{t('AddMagnetOrLink')}</DialogTitle>
|
|
||||||
|
|
||||||
<DialogContent>
|
|
||||||
<TextField onChange={inputTitle} margin='dense' id='title' label={t('Title')} type='text' fullWidth />
|
|
||||||
<TextField onChange={inputPoster} margin='dense' id='poster' label={t('Poster')} type='url' fullWidth />
|
|
||||||
<TextField
|
|
||||||
onChange={inputMagnet}
|
|
||||||
autoFocus
|
|
||||||
margin='dense'
|
|
||||||
id='magnet'
|
|
||||||
label={t('MagnetOrTorrentFileLink')}
|
|
||||||
type='text'
|
|
||||||
fullWidth
|
|
||||||
/>
|
|
||||||
|
|
||||||
<Button color='primary' variant='outlined' component='label'>
|
|
||||||
{t('UploadFile')}
|
|
||||||
<input onChange={handleCapture} type='file' accept='.torrent' hidden />
|
|
||||||
</Button> */}
|
|
||||||
{/* <label htmlFor='upload-file'>
|
|
||||||
<Input onChange={handleCapture} accept='.torrent' type='file' id='upload-file' />
|
|
||||||
<Button htmlFor='upload-file' type='submit' color='primary' variant='outlined'>
|
|
||||||
{t('UploadFile')}
|
|
||||||
</Button>
|
|
||||||
<ListItem button variant='raised' type='submit' component='span' key={t('UploadFile')}>
|
|
||||||
<ListItemIcon>
|
|
||||||
<PublishIcon />
|
|
||||||
</ListItemIcon>
|
|
||||||
|
|
||||||
<ListItemText primary={t('UploadFile')} />
|
|
||||||
</ListItem>
|
|
||||||
</label> */}
|
|
||||||
{/* </DialogContent>
|
|
||||||
|
|
||||||
<DialogActions>
|
|
||||||
<Button onClick={handleClose} color='primary' variant='outlined'>
|
|
||||||
{t('Cancel')}
|
|
||||||
</Button>
|
|
||||||
|
|
||||||
<Button variant='contained' disabled={!link} onClick={handleSave} color='primary'>
|
|
||||||
{t('Add')}
|
|
||||||
</Button>
|
|
||||||
</DialogActions> */}
|
|
||||||
</Dialog>
|
</Dialog>
|
||||||
</>
|
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -72,19 +72,15 @@ export const PiecesLengthWidget = ({ data }) => {
|
|||||||
export const StatusWidget = ({ data }) => {
|
export const StatusWidget = ({ data }) => {
|
||||||
const { t } = useTranslation()
|
const { t } = useTranslation()
|
||||||
let i18nd = data
|
let i18nd = data
|
||||||
if (data.toLowerCase() === 'torrent added')
|
if (data.toLowerCase() === 'torrent added') i18nd = t('TorrentAdded')
|
||||||
i18nd = t('TorrentAdded')
|
else if (data.toLowerCase() === 'torrent getting info') i18nd = t('TorrentGettingInfo')
|
||||||
else if (data.toLowerCase() === 'torrent getting info')
|
else if (data.toLowerCase() === 'torrent preload') i18nd = t('TorrentPreload')
|
||||||
i18nd = t('TorrentGettingInfo')
|
else if (data.toLowerCase() === 'torrent working') i18nd = t('TorrentWorking')
|
||||||
else if (data.toLowerCase() === 'torrent preload')
|
else if (data.toLowerCase() === 'torrent closed') i18nd = t('TorrentClosed')
|
||||||
i18nd = t('TorrentPreload')
|
else if (data.toLowerCase() === 'torrent in db') i18nd = t('TorrentInDb')
|
||||||
else if (data.toLowerCase() === 'torrent working')
|
return (
|
||||||
i18nd = t('TorrentWorking')
|
<StatisticsField title={t('TorrentStatus')} value={i18nd} iconBg='#aea25b' valueBg='#b4aa6e' icon={BuildIcon} />
|
||||||
else if (data.toLowerCase() === 'torrent closed')
|
)
|
||||||
i18nd = t('TorrentClosed')
|
|
||||||
else if (data.toLowerCase() === 'torrent in db')
|
|
||||||
i18nd = t('TorrentInDb')
|
|
||||||
return <StatisticsField title={t('TorrentStatus')} value={i18nd} iconBg='#aea25b' valueBg='#b4aa6e' icon={BuildIcon} />
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export const SizeWidget = ({ data }) => {
|
export const SizeWidget = ({ data }) => {
|
||||||
|
|||||||
@@ -1,33 +0,0 @@
|
|||||||
import ListItemIcon from '@material-ui/core/ListItemIcon'
|
|
||||||
import ListItemText from '@material-ui/core/ListItemText'
|
|
||||||
import ListItem from '@material-ui/core/ListItem'
|
|
||||||
import PublishIcon from '@material-ui/icons/Publish'
|
|
||||||
import { torrentUploadHost } from 'utils/Hosts'
|
|
||||||
import axios from 'axios'
|
|
||||||
import { useTranslation } from 'react-i18next'
|
|
||||||
|
|
||||||
export default function UploadDialog() {
|
|
||||||
const { t } = useTranslation()
|
|
||||||
const handleCapture = ({ target: { files } }) => {
|
|
||||||
const [file] = files
|
|
||||||
const data = new FormData()
|
|
||||||
data.append('save', 'true')
|
|
||||||
data.append('file', file)
|
|
||||||
axios.post(torrentUploadHost(), data)
|
|
||||||
}
|
|
||||||
return (
|
|
||||||
<div>
|
|
||||||
{/* <label htmlFor='upload-file'>
|
|
||||||
<input onChange={handleCapture} accept='.torrent' type='file' style={{ display: 'none' }} id='upload-file' />
|
|
||||||
|
|
||||||
<ListItem button variant='raised' type='submit' component='span' key={t('UploadFile')}>
|
|
||||||
<ListItemIcon>
|
|
||||||
<PublishIcon />
|
|
||||||
</ListItemIcon>
|
|
||||||
|
|
||||||
<ListItemText primary={t('UploadFile')} />
|
|
||||||
</ListItem>
|
|
||||||
</label> */}
|
|
||||||
</div>
|
|
||||||
)
|
|
||||||
}
|
|
||||||
@@ -3,7 +3,7 @@
|
|||||||
"Actions": "Actions",
|
"Actions": "Actions",
|
||||||
"Add": "Add",
|
"Add": "Add",
|
||||||
"AddFromLink": "Add from Link",
|
"AddFromLink": "Add from Link",
|
||||||
"AddMagnetOrLink": "Add magnet or link to torrent file",
|
"AddNewTorrent": "Add new torrent",
|
||||||
"AddRetrackers": "Add retrackers",
|
"AddRetrackers": "Add retrackers",
|
||||||
"Buffer": "Preload Buffer / Cache",
|
"Buffer": "Preload Buffer / Cache",
|
||||||
"BufferNote": "Enable “Preload Buffer” in settings to see cache loading progress",
|
"BufferNote": "Enable “Preload Buffer” in settings to see cache loading progress",
|
||||||
@@ -96,5 +96,11 @@
|
|||||||
"UseDisk": "Use Disk for Cache",
|
"UseDisk": "Use Disk for Cache",
|
||||||
"UseDiskDesc": "Better use external media on flash-based devices",
|
"UseDiskDesc": "Better use external media on flash-based devices",
|
||||||
"UTP": "μTP (Micro Transport Protocol)",
|
"UTP": "μTP (Micro Transport Protocol)",
|
||||||
"Viewed": "Viewed"
|
"Viewed": "Viewed",
|
||||||
|
"AppendFile": {
|
||||||
|
"Or": "OR",
|
||||||
|
"ClickOrDrag": "CLICK / DRAG & DROP"
|
||||||
|
},
|
||||||
|
"TorrentSourceOptions": "magnet / hash / .torrent file link",
|
||||||
|
"Clear": "Clear"
|
||||||
}
|
}
|
||||||
@@ -3,7 +3,7 @@
|
|||||||
"Actions": "Действия",
|
"Actions": "Действия",
|
||||||
"Add": "Добавить",
|
"Add": "Добавить",
|
||||||
"AddFromLink": "Добавить",
|
"AddFromLink": "Добавить",
|
||||||
"AddMagnetOrLink": "Добавьте magnet или ссылку на торрент",
|
"AddNewTorrent": "Добавить новый торрент",
|
||||||
"AddRetrackers": "Добавлять",
|
"AddRetrackers": "Добавлять",
|
||||||
"Buffer": "Предзагрузка / Кеш",
|
"Buffer": "Предзагрузка / Кеш",
|
||||||
"BufferNote": "Включите «Наполнять кеш перед началом воспроизведения» в настройках для показа заполнения кеша",
|
"BufferNote": "Включите «Наполнять кеш перед началом воспроизведения» в настройках для показа заполнения кеша",
|
||||||
@@ -96,5 +96,11 @@
|
|||||||
"UseDisk": "Использовать диск для кеша",
|
"UseDisk": "Использовать диск для кеша",
|
||||||
"UseDiskDesc": "Рекомендуется использовать внешние носители на устройствах с flash-памятью",
|
"UseDiskDesc": "Рекомендуется использовать внешние носители на устройствах с flash-памятью",
|
||||||
"UTP": "μTP (Micro Transport Protocol)",
|
"UTP": "μTP (Micro Transport Protocol)",
|
||||||
"Viewed": "Просм."
|
"Viewed": "Просм.",
|
||||||
|
"AppendFile": {
|
||||||
|
"Or": "ИЛИ",
|
||||||
|
"ClickOrDrag": "НАЖМИТЕ / ПЕРЕТАЩИТЕ ФАЙЛ"
|
||||||
|
},
|
||||||
|
"TorrentSourceOptions": "магнитная ссылка / хэш / ссылка на .torrent файл",
|
||||||
|
"Clear": "Очистить"
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user