From 1736f8a2d026a4978ff757039c6adc48efda6700 Mon Sep 17 00:00:00 2001 From: nikk gitanes Date: Wed, 16 Jun 2021 04:50:52 +0300 Subject: [PATCH 1/6] swap details and format --- .../components/DialogTorrentDetailsContent/index.jsx | 12 ++++++------ web/src/utils/Utils.js | 4 ++-- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/web/src/components/DialogTorrentDetailsContent/index.jsx b/web/src/components/DialogTorrentDetailsContent/index.jsx index f111305..158ac23 100644 --- a/web/src/components/DialogTorrentDetailsContent/index.jsx +++ b/web/src/components/DialogTorrentDetailsContent/index.jsx @@ -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/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 ? '…' : '') : '' From 4c400cae099784eed5d3d764c724646e5e4dcacb Mon Sep 17 00:00:00 2001 From: nikk gitanes Date: Wed, 16 Jun 2021 05:00:26 +0300 Subject: [PATCH 2/6] revert details --- web/src/components/TorrentCard/index.jsx | 40 ++---------------------- web/src/components/TorrentCard/style.js | 16 ++++------ web/src/locales/en/translation.json | 4 +-- web/src/locales/ru/translation.json | 4 +-- 4 files changed, 10 insertions(+), 54 deletions(-) diff --git a/web/src/components/TorrentCard/index.jsx b/web/src/components/TorrentCard/index.jsx index e3936ad..dc88def 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,7 @@ const Torrent = ({ torrent }) => { const dropTorrent = () => axios.post(torrentsHost(), { action: 'drop', hash }) const deleteTorrent = () => axios.post(torrentsHost(), { action: 'rem', hash }) - const getParsedData = () => { - const parse = key => ptt.parse(title || '')?.[key] || ptt.parse(name || '')?.[key] - - const parsedYear = parse('year') - const parsedResolution = parse('resolution') - const parsedTitle = parse('title') - - return { parsedResolution, parsedYear, parsedTitle } - } - - const { parsedResolution, parsedYear, parsedTitle } = getParsedData() - - const playableFileAmount = torrent.file_stats?.filter(({ path }) => isFilePlayable(path))?.length + const parsedTitle = (title || name) && ptt.parse(title || name).title const [isEditDialogOpen, setIsEditDialogOpen] = useState(false) const handleClickOpenEditDialog = () => setIsEditDialogOpen(true) @@ -94,29 +81,6 @@ const Torrent = ({ torrent }) => {
{shortenText(parsedTitle, 100)}
-
- {parsedResolution && ( -
-
{t('Resolution')}
-
{parsedResolution}
-
- )} - - {parsedYear && ( -
-
{t('Year')}
-
{parsedYear}
-
- )} - - {playableFileAmount > 1 && ( -
-
{t('Files')}
-
{playableFileAmount}
-
- )} -
-
{t('Size')}
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..02e894a 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", @@ -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..aa93941 100644 --- a/web/src/locales/ru/translation.json +++ b/web/src/locales/ru/translation.json @@ -48,7 +48,6 @@ "EditTorrent": "Изменить торрент", "EnableIPv6": "IPv6", "Episode": "Серия", - "Files": "Файлы", "ForceEncrypt": "Принудительное шифрование заголовков", "FromLatestFile": "C последнего файла", "Full": "Полный", @@ -114,6 +113,5 @@ "UseDiskDesc": "Рекомендуется использовать внешние носители на устройствах с flash-памятью", "UTP": "μTP (Micro Transport Protocol)", "Viewed": "Просм.", - "WrongTorrentSource": "Неправильный torrent-источник", - "Year": "Год" + "WrongTorrentSource": "Неправильный torrent-источник" } \ No newline at end of file From 086d70b0cf242e997c662f7fc28641a8b23a16de Mon Sep 17 00:00:00 2001 From: nikk gitanes Date: Wed, 16 Jun 2021 05:17:44 +0300 Subject: [PATCH 3/6] use long titles with year and res --- .../DialogTorrentDetailsContent/index.jsx | 2 +- web/src/components/TorrentCard/index.jsx | 16 ++++++++++++++-- 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/web/src/components/DialogTorrentDetailsContent/index.jsx b/web/src/components/DialogTorrentDetailsContent/index.jsx index 158ac23..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' diff --git a/web/src/components/TorrentCard/index.jsx b/web/src/components/TorrentCard/index.jsx index dc88def..8106af8 100644 --- a/web/src/components/TorrentCard/index.jsx +++ b/web/src/components/TorrentCard/index.jsx @@ -40,7 +40,19 @@ const Torrent = ({ torrent }) => { const dropTorrent = () => axios.post(torrentsHost(), { action: 'drop', hash }) const deleteTorrent = () => axios.post(torrentsHost(), { action: 'rem', hash }) - const parsedTitle = (title || name) && ptt.parse(title || name).title + 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') + if (parsedTitle) titleStrings.push(parsedTitle) + if (parsedYear) titleStrings.push(`(${parsedYear})`) + if (parsedResolution) titleStrings.push(`[${parsedResolution}]`) + parsedTitle = titleStrings.join(' ') + return { parsedTitle } + } + const { parsedTitle } = getParsedTitle() const [isEditDialogOpen, setIsEditDialogOpen] = useState(false) const handleClickOpenEditDialog = () => setIsEditDialogOpen(true) @@ -78,7 +90,7 @@ const Torrent = ({ torrent }) => {
{t('Name')}
-
{shortenText(parsedTitle, 100)}
+
{shortenText(parsedTitle, 255)}
From 8ef4ab8a1222824d6214445968ce9166985a4815 Mon Sep 17 00:00:00 2001 From: nikk gitanes Date: Wed, 16 Jun 2021 07:05:54 +0300 Subject: [PATCH 4/6] locales update --- web/src/locales/en/translation.json | 2 +- web/src/locales/ru/translation.json | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/web/src/locales/en/translation.json b/web/src/locales/en/translation.json index 02e894a..b9003d3 100644 --- a/web/src/locales/en/translation.json +++ b/web/src/locales/en/translation.json @@ -59,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", diff --git a/web/src/locales/ru/translation.json b/web/src/locales/ru/translation.json index aa93941..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": "Ссылка на постер", @@ -59,7 +59,7 @@ "Offline": "Сервер не доступен", "OK": "OK", "OpenLink": "Открыть", - "Peers": "Подкл./Пиры", + "Peers": "[Подкл.] Пиры", "PeersListenPort": "Порт для входящих подключений", "PEX": "PEX (Peer Exchange)", "PiecesCount": "Кол-во блоков", From b44caaa422e1642213f387fff315fa41cb0bc4eb Mon Sep 17 00:00:00 2001 From: nikk gitanes Date: Wed, 16 Jun 2021 09:08:42 +0300 Subject: [PATCH 5/6] simplify snake colors and fix border --- .../DialogTorrentDetailsContent/TorrentCache/snakeSettings.js | 2 +- .../DialogTorrentDetailsContent/TorrentCache/style.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/web/src/components/DialogTorrentDetailsContent/TorrentCache/snakeSettings.js b/web/src/components/DialogTorrentDetailsContent/TorrentCache/snakeSettings.js index 82c4463..aab98d9 100644 --- a/web/src/components/DialogTorrentDetailsContent/TorrentCache/snakeSettings.js +++ b/web/src/components/DialogTorrentDetailsContent/TorrentCache/snakeSettings.js @@ -9,4 +9,4 @@ 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)}%; ` From ce0298bcea2f53fc92ec06324b93e8e0e583714a Mon Sep 17 00:00:00 2001 From: nikk gitanes Date: Wed, 16 Jun 2021 10:40:01 +0300 Subject: [PATCH 6/6] Update snakeSettings.js --- .../DialogTorrentDetailsContent/TorrentCache/snakeSettings.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/web/src/components/DialogTorrentDetailsContent/TorrentCache/snakeSettings.js b/web/src/components/DialogTorrentDetailsContent/TorrentCache/snakeSettings.js index aab98d9..4621717 100644 --- a/web/src/components/DialogTorrentDetailsContent/TorrentCache/snakeSettings.js +++ b/web/src/components/DialogTorrentDetailsContent/TorrentCache/snakeSettings.js @@ -4,7 +4,7 @@ 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'