diff --git a/web/src/components/DialogTorrentDetailsContent/TorrentCache/snakeSettings.js b/web/src/components/DialogTorrentDetailsContent/TorrentCache/snakeSettings.js index 82c4463..4621717 100644 --- a/web/src/components/DialogTorrentDetailsContent/TorrentCache/snakeSettings.js +++ b/web/src/components/DialogTorrentDetailsContent/TorrentCache/snakeSettings.js @@ -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' diff --git a/web/src/components/DialogTorrentDetailsContent/TorrentCache/style.js b/web/src/components/DialogTorrentDetailsContent/TorrentCache/style.js index 532a6d3..0c7584d 100644 --- a/web/src/components/DialogTorrentDetailsContent/TorrentCache/style.js +++ b/web/src/components/DialogTorrentDetailsContent/TorrentCache/style.js @@ -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)}%; ` diff --git a/web/src/components/DialogTorrentDetailsContent/index.jsx b/web/src/components/DialogTorrentDetailsContent/index.jsx index f111305..3311fcb 100644 --- a/web/src/components/DialogTorrentDetailsContent/index.jsx +++ b/web/src/components/DialogTorrentDetailsContent/index.jsx @@ -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 }) {
{title && name !== title ? ( <> - {shortenText(getParsedTitle(), 55)} - {shortenText(ptt.parse(name).title, 110)} + {ptt.parse(name).title} + {getParsedTitle()} ) : ( - {shortenText(getParsedTitle(), 55)} + {getParsedTitle()} )} diff --git a/web/src/components/TorrentCard/index.jsx b/web/src/components/TorrentCard/index.jsx index e3936ad..8106af8 100644 --- a/web/src/components/TorrentCard/index.jsx +++ b/web/src/components/TorrentCard/index.jsx @@ -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 }) => {
{t('Name')}
-
{shortenText(parsedTitle, 100)}
-
- -
- {parsedResolution && ( -
-
{t('Resolution')}
-
{parsedResolution}
-
- )} - - {parsedYear && ( -
-
{t('Year')}
-
{parsedYear}
-
- )} - - {playableFileAmount > 1 && ( -
-
{t('Files')}
-
{playableFileAmount}
-
- )} +
{shortenText(parsedTitle, 255)}
diff --git a/web/src/components/TorrentCard/style.js b/web/src/components/TorrentCard/style.js index cd5dad7..31ca13f 100644 --- a/web/src/components/TorrentCard/style.js +++ b/web/src/components/TorrentCard/style.js @@ -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; } diff --git a/web/src/locales/en/translation.json b/web/src/locales/en/translation.json index 7264978..b9003d3 100644 --- a/web/src/locales/en/translation.json +++ b/web/src/locales/en/translation.json @@ -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" } \ No newline at end of file diff --git a/web/src/locales/ru/translation.json b/web/src/locales/ru/translation.json index b4ad1b3..70b6631 100644 --- a/web/src/locales/ru/translation.json +++ b/web/src/locales/ru/translation.json @@ -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-источник" } \ No newline at end of file diff --git a/web/src/utils/Utils.js b/web/src/utils/Utils.js index 06289f7..1e1bac5 100644 --- a/web/src/utils/Utils.js +++ b/web/src/utils/Utils.js @@ -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 ? '…' : '') : ''