Merge branch 'details-in-card-and-add-dialog-title-change' of https://github.com/YouROK/TorrServer into details-in-card-and-add-dialog-title-change

This commit is contained in:
Daniel Shleifman
2021-06-16 11:41:31 +03:00
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;
}