Merge pull request #70 from tsynik/master

change details in card and list
This commit is contained in:
dancheskus
2021-06-16 11:41:24 +03:00
committed by GitHub
8 changed files with 34 additions and 66 deletions

View File

@@ -4,9 +4,9 @@ export const pieceSizeForMiniMap = 23
export const gapBetweenPieces = 3
export const miniCacheMaxHeight = 340
export const defaultBorderColor = '#eef2f4'
export const defaultBorderColor = '#dbf2e8'
export const defaultBackgroundColor = '#fff'
export const completeColor = '#00a572'
export const progressColor = '#ffa724'
export const activeColor = '#000'
export const rangeColor = '#9a9aff'
export const rangeColor = '#ffa724'

View File

@@ -62,5 +62,5 @@ export const SnakeWrapper = styled.div`
export const PercentagePiece = styled.div`
background: ${completeColor};
height: ${({ percentage }) => (percentage / 100) * 12}px;
height: ${({ percentage }) => (percentage)}%;
`

View File

@@ -1,5 +1,5 @@
import { NoImageIcon } from 'icons'
import { humanizeSize, shortenText } from 'utils/Utils'
import { humanizeSize } from 'utils/Utils'
import { useEffect, useState } from 'react'
import { Button, ButtonGroup } from '@material-ui/core'
import ptt from 'parse-torrent-title'
@@ -110,10 +110,10 @@ export default function DialogTorrentDetailsContent({ closeDialog, torrent }) {
newNameStrings.push(title)
} else if (torrentParsedName?.title) newNameStrings.push(torrentParsedName?.title)
if (torrentParsedName?.year) newNameStrings.push(torrentParsedName?.year)
if (torrentParsedName?.resolution) newNameStrings.push(torrentParsedName?.resolution)
// if (torrentParsedName?.year) newNameStrings.push(torrentParsedName?.year)
// if (torrentParsedName?.resolution) newNameStrings.push(torrentParsedName?.resolution)
return newNameStrings.join('. ')
return newNameStrings.join(' ')
}
return (
@@ -146,11 +146,11 @@ export default function DialogTorrentDetailsContent({ closeDialog, torrent }) {
<div>
{title && name !== title ? (
<>
<SectionTitle>{shortenText(getParsedTitle(), 55)}</SectionTitle>
<SectionSubName mb={20}>{shortenText(ptt.parse(name).title, 110)}</SectionSubName>
<SectionTitle>{ptt.parse(name).title}</SectionTitle>
<SectionSubName mb={20}>{getParsedTitle()}</SectionSubName>
</>
) : (
<SectionTitle mb={20}>{shortenText(getParsedTitle(), 55)}</SectionTitle>
<SectionTitle mb={20}>{getParsedTitle()}</SectionTitle>
)}
<WidgetWrapper>

View File

@@ -1,6 +1,5 @@
import 'fontsource-roboto'
import { forwardRef, memo, useState } from 'react'
import ptt from 'parse-torrent-title'
import {
UnfoldMore as UnfoldMoreIcon,
Edit as EditIcon,
@@ -15,9 +14,9 @@ import Dialog from '@material-ui/core/Dialog'
import Slide from '@material-ui/core/Slide'
import { Button, DialogActions, DialogTitle, useMediaQuery, useTheme } from '@material-ui/core'
import axios from 'axios'
import ptt from 'parse-torrent-title'
import { useTranslation } from 'react-i18next'
import AddDialog from 'components/Add/AddDialog'
import { isFilePlayable } from 'components/DialogTorrentDetailsContent/helpers'
import { StyledButton, TorrentCard, TorrentCardButtons, TorrentCardDescription, TorrentCardPoster } from './style'
@@ -41,19 +40,19 @@ const Torrent = ({ torrent }) => {
const dropTorrent = () => axios.post(torrentsHost(), { action: 'drop', hash })
const deleteTorrent = () => axios.post(torrentsHost(), { action: 'rem', hash })
const getParsedData = () => {
const getParsedTitle = () => {
const parse = key => ptt.parse(title || '')?.[key] || ptt.parse(name || '')?.[key]
const titleStrings = []
let parsedTitle = parse('title')
const parsedYear = parse('year')
const parsedResolution = parse('resolution')
const parsedTitle = parse('title')
return { parsedResolution, parsedYear, parsedTitle }
if (parsedTitle) titleStrings.push(parsedTitle)
if (parsedYear) titleStrings.push(`(${parsedYear})`)
if (parsedResolution) titleStrings.push(`[${parsedResolution}]`)
parsedTitle = titleStrings.join(' ')
return { parsedTitle }
}
const { parsedResolution, parsedYear, parsedTitle } = getParsedData()
const playableFileAmount = torrent.file_stats?.filter(({ path }) => isFilePlayable(path))?.length
const { parsedTitle } = getParsedTitle()
const [isEditDialogOpen, setIsEditDialogOpen] = useState(false)
const handleClickOpenEditDialog = () => setIsEditDialogOpen(true)
@@ -91,30 +90,7 @@ const Torrent = ({ torrent }) => {
<TorrentCardDescription>
<div className='description-title-wrapper'>
<div className='description-section-name'>{t('Name')}</div>
<div className='description-torrent-title'>{shortenText(parsedTitle, 100)}</div>
</div>
<div className='description-statistics-wrapper'>
{parsedResolution && (
<div className='description-statistics-element-wrapper'>
<div className='description-section-name'>{t('Resolution')}</div>
<div className='description-statistics-element-value'>{parsedResolution}</div>
</div>
)}
{parsedYear && (
<div className='description-statistics-element-wrapper'>
<div className='description-section-name'>{t('Year')}</div>
<div className='description-statistics-element-value'>{parsedYear}</div>
</div>
)}
{playableFileAmount > 1 && (
<div className='description-statistics-element-wrapper'>
<div className='description-section-name'>{t('Files')}</div>
<div className='description-statistics-element-value'>{playableFileAmount}</div>
</div>
)}
<div className='description-torrent-title'>{shortenText(parsedTitle, 255)}</div>
</div>
<div className='description-statistics-wrapper'>

View File

@@ -16,13 +16,13 @@ export const TorrentCard = styled.div`
'poster description'
'buttons buttons';
grid-template-columns: 90px 1fr;
grid-template-rows: 130px max-content;
grid-template-columns: 70px 1fr;
grid-template-rows: 110px max-content;
}
@media (max-width: 770px) {
grid-template-columns: 80px 1fr;
grid-template-rows: 110px max-content;
grid-template-columns: 60px 1fr;
grid-template-rows: 90px max-content;
}
`
@@ -79,15 +79,11 @@ export const TorrentCardDescription = styled.div`
border-radius: 5px;
padding: 5px;
display: grid;
grid-template-rows: 40% 1fr 1fr;
grid-template-rows: 55% 1fr;
gap: 10px;
@media (max-width: 1260px) {
grid-template-rows: max-content 1fr 1fr;
}
@media (max-width: 770px) {
grid-template-rows: 35% 1fr 1fr;
grid-template-rows: 60% 1fr;
gap: 3px;
}

View File

@@ -48,7 +48,6 @@
"EditTorrent": "Edit torrent",
"EnableIPv6": "IPv6",
"Episode": "Episode",
"Files": "Files",
"ForceEncrypt": "Force Encrypt Headers",
"FromLatestFile": "From Latest File",
"Full": "Full",
@@ -60,7 +59,7 @@
"Offline": "Offline",
"OK": "OK",
"OpenLink": "Open link",
"Peers": "Peers",
"Peers": "[Connected] Peers",
"PeersListenPort": "Peers Listen Port",
"PEX": "PEX (Peer Exchange)",
"PiecesCount": "Pieces count",
@@ -114,6 +113,5 @@
"UseDiskDesc": "Better use external media on flash-based devices",
"UTP": "μTP (Micro Transport Protocol)",
"Viewed": "Viewed",
"WrongTorrentSource": "Wrong torrent source",
"Year": "Year"
"WrongTorrentSource": "Wrong torrent source"
}

View File

@@ -2,7 +2,7 @@
"About": "О сервере",
"Actions": "Действия",
"Add": "Добавить",
"AddDialogTorrentTitle": "Имя (пустой для имени из торрента)",
"AddDialogTorrentTitle": "Название (оставьте пустым для имени из торрента)",
"AddFromLink": "Добавить",
"AddNewTorrent": "Добавить новый торрент",
"AddPosterLinkInput": "Ссылка на постер",
@@ -48,7 +48,6 @@
"EditTorrent": "Изменить торрент",
"EnableIPv6": "IPv6",
"Episode": "Серия",
"Files": "Файлы",
"ForceEncrypt": "Принудительное шифрование заголовков",
"FromLatestFile": "C последнего файла",
"Full": "Полный",
@@ -60,7 +59,7 @@
"Offline": "Сервер не доступен",
"OK": "OK",
"OpenLink": "Открыть",
"Peers": "Подкл./Пиры",
"Peers": "[Подкл.] Пиры",
"PeersListenPort": "Порт для входящих подключений",
"PEX": "PEX (Peer Exchange)",
"PiecesCount": "Кол-во блоков",
@@ -114,6 +113,5 @@
"UseDiskDesc": "Рекомендуется использовать внешние носители на устройствах с flash-памятью",
"UTP": "μTP (Micro Transport Protocol)",
"Viewed": "Просм.",
"WrongTorrentSource": "Неправильный torrent-источник",
"Year": "Год"
"WrongTorrentSource": "Неправильный torrent-источник"
}

View File

@@ -1,7 +1,7 @@
export function humanizeSize(size) {
if (!size) return ''
const i = Math.floor(Math.log(size) / Math.log(1024))
return `${(size / Math.pow(1024, i)).toFixed(2) * 1} ${['B', 'kB', 'MB', 'GB', 'TB'][i]}`
return `${(size / Math.pow(1024, i)).toFixed(2) * 1} ${['B', 'KB', 'MB', 'GB', 'TB'][i]}`
}
export function getPeerString(torrent) {
@@ -10,4 +10,4 @@ export function getPeerString(torrent) {
}
export const shortenText = (text, sympolAmount) =>
text ? text.slice(0, sympolAmount) + (text.length > sympolAmount ? '...' : '') : ''
text ? text.slice(0, sympolAmount) + (text.length > sympolAmount ? '' : '') : ''