mirror of
https://github.com/Ernous/TorrServerJellyfin.git
synced 2025-12-19 21:46:11 +05:00
dropzone added
This commit is contained in:
@@ -18,6 +18,7 @@
|
|||||||
"react-copy-to-clipboard": "^5.0.3",
|
"react-copy-to-clipboard": "^5.0.3",
|
||||||
"react-div-100vh": "^0.6.0",
|
"react-div-100vh": "^0.6.0",
|
||||||
"react-dom": "^17.0.2",
|
"react-dom": "^17.0.2",
|
||||||
|
"react-dropzone": "^11.3.2",
|
||||||
"react-i18next": "^11.10.0",
|
"react-i18next": "^11.10.0",
|
||||||
"react-konva": "^17.0.2-4",
|
"react-konva": "^17.0.2-4",
|
||||||
"react-measure": "^2.5.2",
|
"react-measure": "^2.5.2",
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
import { useMemo, useState } from 'react'
|
import { useCallback, 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'
|
||||||
@@ -11,6 +11,7 @@ import debounce from 'lodash/debounce'
|
|||||||
import { v4 as uuidv4 } from 'uuid'
|
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'
|
||||||
|
import { useDropzone } from 'react-dropzone'
|
||||||
|
|
||||||
const Header = styled.div`
|
const Header = styled.div`
|
||||||
background: #00a572;
|
background: #00a572;
|
||||||
@@ -46,7 +47,7 @@ const RightSide = styled.div`
|
|||||||
`
|
`
|
||||||
|
|
||||||
const RightSideBottomSectionBasicStyles = css`
|
const RightSideBottomSectionBasicStyles = css`
|
||||||
transition: all 0.3s;
|
transition: transform 0.3s;
|
||||||
padding: 20px;
|
padding: 20px;
|
||||||
height: 100%;
|
height: 100%;
|
||||||
display: grid;
|
display: grid;
|
||||||
@@ -54,6 +55,9 @@ const RightSideBottomSectionBasicStyles = css`
|
|||||||
|
|
||||||
const RightSideBottomSectionNoFile = styled.div`
|
const RightSideBottomSectionNoFile = styled.div`
|
||||||
${RightSideBottomSectionBasicStyles}
|
${RightSideBottomSectionBasicStyles}
|
||||||
|
border: 4px dashed transparent;
|
||||||
|
|
||||||
|
${({ isDragActive }) => isDragActive && `border: 4px dashed green`};
|
||||||
|
|
||||||
justify-items: center;
|
justify-items: center;
|
||||||
grid-template-rows: 100px 1fr;
|
grid-template-rows: 100px 1fr;
|
||||||
@@ -103,11 +107,6 @@ const IconWrapper = styled.div`
|
|||||||
}
|
}
|
||||||
`
|
`
|
||||||
|
|
||||||
const FileUploadLabel = styled.label`
|
|
||||||
transition: all 0.3s;
|
|
||||||
flex: 1;
|
|
||||||
`
|
|
||||||
|
|
||||||
const RightSideTopSection = styled.div`
|
const RightSideTopSection = styled.div`
|
||||||
background: #fff;
|
background: #fff;
|
||||||
padding: 0 20px 20px 20px;
|
padding: 0 20px 20px 20px;
|
||||||
@@ -115,7 +114,7 @@ const RightSideTopSection = styled.div`
|
|||||||
${({ active }) =>
|
${({ active }) =>
|
||||||
active &&
|
active &&
|
||||||
css`
|
css`
|
||||||
+ ${FileUploadLabel} {
|
+ ${RightSideBottomSectionNoFile} {
|
||||||
box-shadow: inset 3px 25px 8px -25px rgba(0, 0, 0, 0.5);
|
box-shadow: inset 3px 25px 8px -25px rgba(0, 0, 0, 0.5);
|
||||||
}
|
}
|
||||||
`};
|
`};
|
||||||
@@ -238,6 +237,16 @@ export default function AddDialog({ handleClose }) {
|
|||||||
const [currentLang] = useChangeLanguage()
|
const [currentLang] = useChangeLanguage()
|
||||||
const [selectedFile, setSelectedFile] = useState()
|
const [selectedFile, setSelectedFile] = useState()
|
||||||
|
|
||||||
|
const handleCapture = useCallback(files => {
|
||||||
|
const [file] = files
|
||||||
|
if (!file) return
|
||||||
|
|
||||||
|
setSelectedFile(file)
|
||||||
|
setTorrentSource(file.name)
|
||||||
|
}, [])
|
||||||
|
|
||||||
|
const { getRootProps, getInputProps, isDragActive } = useDropzone({ onDrop: handleCapture, accept: '.torrent' })
|
||||||
|
|
||||||
const removePoster = () => {
|
const removePoster = () => {
|
||||||
setIsPosterUrlCorrect(false)
|
setIsPosterUrlCorrect(false)
|
||||||
setPosterUrl('')
|
setPosterUrl('')
|
||||||
@@ -296,14 +305,6 @@ export default function AddDialog({ handleClose }) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const handleCapture = ({ target: { files } }) => {
|
|
||||||
const [file] = files
|
|
||||||
if (!file) return
|
|
||||||
|
|
||||||
setSelectedFile(file)
|
|
||||||
setTorrentSource(file.name)
|
|
||||||
}
|
|
||||||
|
|
||||||
const clearSelectedFile = () => {
|
const clearSelectedFile = () => {
|
||||||
setSelectedFile()
|
setSelectedFile()
|
||||||
setTorrentSource('')
|
setTorrentSource('')
|
||||||
@@ -396,24 +397,15 @@ export default function AddDialog({ handleClose }) {
|
|||||||
</TorrentIconWrapper>
|
</TorrentIconWrapper>
|
||||||
</RightSideBottomSectionFileSelected>
|
</RightSideBottomSectionFileSelected>
|
||||||
) : (
|
) : (
|
||||||
<FileUploadLabel htmlFor='upload-file'>
|
<RightSideBottomSectionNoFile isDragActive={isDragActive} {...getRootProps()}>
|
||||||
<input
|
<input {...getInputProps()} />
|
||||||
onChange={handleCapture}
|
<div>{t('AppendFile.Or')}</div>
|
||||||
accept='.torrent'
|
|
||||||
type='file'
|
|
||||||
style={{ display: 'none' }}
|
|
||||||
id='upload-file'
|
|
||||||
/>
|
|
||||||
|
|
||||||
<RightSideBottomSectionNoFile selectedFile={selectedFile} type='submit'>
|
<IconWrapper>
|
||||||
<div>{t('AppendFile.Or')}</div>
|
<AddItemIcon color='primary' />
|
||||||
|
<div>{t('AppendFile.ClickOrDrag')}</div>
|
||||||
<IconWrapper>
|
</IconWrapper>
|
||||||
<AddItemIcon color='primary' />
|
</RightSideBottomSectionNoFile>
|
||||||
<div>{t('AppendFile.ClickOrDrag')}</div>
|
|
||||||
</IconWrapper>
|
|
||||||
</RightSideBottomSectionNoFile>
|
|
||||||
</FileUploadLabel>
|
|
||||||
)}
|
)}
|
||||||
</RightSide>
|
</RightSide>
|
||||||
</Content>
|
</Content>
|
||||||
|
|||||||
Binary file not shown.
@@ -99,7 +99,7 @@
|
|||||||
"Viewed": "Viewed",
|
"Viewed": "Viewed",
|
||||||
"AppendFile": {
|
"AppendFile": {
|
||||||
"Or": "OR",
|
"Or": "OR",
|
||||||
"ClickOrDrag": "CLICK / DRAG & DROP"
|
"ClickOrDrag": "CLICK / DRAG & DROP (.torrent)"
|
||||||
},
|
},
|
||||||
"TorrentSourceOptions": "magnet / hash / .torrent file link",
|
"TorrentSourceOptions": "magnet / hash / .torrent file link",
|
||||||
"Clear": "Clear"
|
"Clear": "Clear"
|
||||||
|
|||||||
@@ -99,7 +99,7 @@
|
|||||||
"Viewed": "Просм.",
|
"Viewed": "Просм.",
|
||||||
"AppendFile": {
|
"AppendFile": {
|
||||||
"Or": "ИЛИ",
|
"Or": "ИЛИ",
|
||||||
"ClickOrDrag": "НАЖМИТЕ / ПЕРЕТАЩИТЕ ФАЙЛ"
|
"ClickOrDrag": "НАЖМИТЕ / ПЕРЕТАЩИТЕ ФАЙЛ (.torrent)"
|
||||||
},
|
},
|
||||||
"TorrentSourceOptions": "магнитная ссылка / хэш / ссылка на .torrent файл",
|
"TorrentSourceOptions": "магнитная ссылка / хэш / ссылка на .torrent файл",
|
||||||
"Clear": "Очистить"
|
"Clear": "Очистить"
|
||||||
|
|||||||
@@ -2730,6 +2730,11 @@ atob@^2.1.2:
|
|||||||
resolved "https://registry.yarnpkg.com/atob/-/atob-2.1.2.tgz#6d9517eb9e030d2436666651e86bd9f6f13533c9"
|
resolved "https://registry.yarnpkg.com/atob/-/atob-2.1.2.tgz#6d9517eb9e030d2436666651e86bd9f6f13533c9"
|
||||||
integrity sha512-Wm6ukoaOGJi/73p/cl2GvLjTI5JM1k/O14isD73YML8StrH/7/lRFgmg8nICZgD3bZZvjwCGxtMOD3wWNAu8cg==
|
integrity sha512-Wm6ukoaOGJi/73p/cl2GvLjTI5JM1k/O14isD73YML8StrH/7/lRFgmg8nICZgD3bZZvjwCGxtMOD3wWNAu8cg==
|
||||||
|
|
||||||
|
attr-accept@^2.2.1:
|
||||||
|
version "2.2.2"
|
||||||
|
resolved "https://registry.yarnpkg.com/attr-accept/-/attr-accept-2.2.2.tgz#646613809660110749e92f2c10833b70968d929b"
|
||||||
|
integrity sha512-7prDjvt9HmqiZ0cl5CRjtS84sEyhsHP2coDkaZKRKVfCDo9s7iw7ChVmar78Gu9pC4SoR/28wFu/G5JJhTnqEg==
|
||||||
|
|
||||||
autoprefixer@^9.6.1:
|
autoprefixer@^9.6.1:
|
||||||
version "9.8.6"
|
version "9.8.6"
|
||||||
resolved "https://registry.yarnpkg.com/autoprefixer/-/autoprefixer-9.8.6.tgz#3b73594ca1bf9266320c5acf1588d74dea74210f"
|
resolved "https://registry.yarnpkg.com/autoprefixer/-/autoprefixer-9.8.6.tgz#3b73594ca1bf9266320c5acf1588d74dea74210f"
|
||||||
@@ -5591,6 +5596,13 @@ file-loader@6.1.1:
|
|||||||
loader-utils "^2.0.0"
|
loader-utils "^2.0.0"
|
||||||
schema-utils "^3.0.0"
|
schema-utils "^3.0.0"
|
||||||
|
|
||||||
|
file-selector@^0.2.2:
|
||||||
|
version "0.2.4"
|
||||||
|
resolved "https://registry.yarnpkg.com/file-selector/-/file-selector-0.2.4.tgz#7b98286f9dbb9925f420130ea5ed0a69238d4d80"
|
||||||
|
integrity sha512-ZDsQNbrv6qRi1YTDOEWzf5J2KjZ9KMI1Q2SGeTkCJmNNW25Jg4TW4UMcmoqcg4WrAyKRcpBXdbWRxkfrOzVRbA==
|
||||||
|
dependencies:
|
||||||
|
tslib "^2.0.3"
|
||||||
|
|
||||||
file-uri-to-path@1.0.0:
|
file-uri-to-path@1.0.0:
|
||||||
version "1.0.0"
|
version "1.0.0"
|
||||||
resolved "https://registry.yarnpkg.com/file-uri-to-path/-/file-uri-to-path-1.0.0.tgz#553a7b8446ff6f684359c445f1e37a05dacc33dd"
|
resolved "https://registry.yarnpkg.com/file-uri-to-path/-/file-uri-to-path-1.0.0.tgz#553a7b8446ff6f684359c445f1e37a05dacc33dd"
|
||||||
@@ -10322,6 +10334,15 @@ react-dom@^17.0.2:
|
|||||||
object-assign "^4.1.1"
|
object-assign "^4.1.1"
|
||||||
scheduler "^0.20.2"
|
scheduler "^0.20.2"
|
||||||
|
|
||||||
|
react-dropzone@^11.3.2:
|
||||||
|
version "11.3.2"
|
||||||
|
resolved "https://registry.yarnpkg.com/react-dropzone/-/react-dropzone-11.3.2.tgz#2efb6af800a4779a9daa1e7ba1f8d51d0ab862d7"
|
||||||
|
integrity sha512-Z0l/YHcrNK1r85o6RT77Z5XgTARmlZZGfEKBl3tqTXL9fZNQDuIdRx/J0QjvR60X+yYu26dnHeaG2pWU+1HHvw==
|
||||||
|
dependencies:
|
||||||
|
attr-accept "^2.2.1"
|
||||||
|
file-selector "^0.2.2"
|
||||||
|
prop-types "^15.7.2"
|
||||||
|
|
||||||
react-error-overlay@^6.0.9:
|
react-error-overlay@^6.0.9:
|
||||||
version "6.0.9"
|
version "6.0.9"
|
||||||
resolved "https://registry.yarnpkg.com/react-error-overlay/-/react-error-overlay-6.0.9.tgz#3c743010c9359608c375ecd6bc76f35d93995b0a"
|
resolved "https://registry.yarnpkg.com/react-error-overlay/-/react-error-overlay-6.0.9.tgz#3c743010c9359608c375ecd6bc76f35d93995b0a"
|
||||||
|
|||||||
Reference in New Issue
Block a user