mirror of
https://github.com/Ernous/TorrServerJellyfin.git
synced 2025-12-19 21:46:11 +05:00
DebugMode toggle added
This commit is contained in:
@@ -1,4 +1,6 @@
|
|||||||
import { useTranslation } from 'react-i18next'
|
import { useTranslation } from 'react-i18next'
|
||||||
|
import { Checkbox, FormControlLabel } from '@material-ui/core'
|
||||||
|
import { useState } from 'react'
|
||||||
|
|
||||||
import { SectionTitle, WidgetWrapper } from '../style'
|
import { SectionTitle, WidgetWrapper } from '../style'
|
||||||
import { DetailedViewCacheSection, DetailedViewWidgetSection } from './style'
|
import { DetailedViewCacheSection, DetailedViewWidgetSection } from './style'
|
||||||
@@ -24,6 +26,9 @@ export default function DetailedView({
|
|||||||
cache,
|
cache,
|
||||||
}) {
|
}) {
|
||||||
const { t } = useTranslation()
|
const { t } = useTranslation()
|
||||||
|
const [isSnakeDebugMode, setIsSnakeDebugMode] = useState(
|
||||||
|
JSON.parse(localStorage.getItem('isSnakeDebugMode')) || false,
|
||||||
|
)
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
@@ -43,9 +48,25 @@ export default function DetailedView({
|
|||||||
|
|
||||||
<DetailedViewCacheSection>
|
<DetailedViewCacheSection>
|
||||||
<SectionTitle color='#000' mb={20}>
|
<SectionTitle color='#000' mb={20}>
|
||||||
{t('Cache')}
|
<div style={{ display: 'flex', justifyContent: 'space-between', alignItems: 'center' }}>
|
||||||
|
<span>{t('Cache')}</span>
|
||||||
|
|
||||||
|
<FormControlLabel
|
||||||
|
control={
|
||||||
|
<Checkbox
|
||||||
|
checked={isSnakeDebugMode}
|
||||||
|
onChange={({ target: { checked } }) => {
|
||||||
|
setIsSnakeDebugMode(checked)
|
||||||
|
localStorage.setItem('isSnakeDebugMode', checked)
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
}
|
||||||
|
label={t('DebugMode')}
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
</SectionTitle>
|
</SectionTitle>
|
||||||
<TorrentCache cache={cache} />
|
|
||||||
|
<TorrentCache cache={cache} isSnakeDebugMode={isSnakeDebugMode} />
|
||||||
</DetailedViewCacheSection>
|
</DetailedViewCacheSection>
|
||||||
</>
|
</>
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ import getShortCacheMap from './getShortCacheMap'
|
|||||||
import { SnakeWrapper, ScrollNotification } from './style'
|
import { SnakeWrapper, ScrollNotification } from './style'
|
||||||
import { createGradient, snakeSettings } from './snakeSettings'
|
import { createGradient, snakeSettings } from './snakeSettings'
|
||||||
|
|
||||||
const TorrentCache = ({ cache, isMini }) => {
|
const TorrentCache = ({ cache, isMini, isSnakeDebugMode }) => {
|
||||||
const { t } = useTranslation()
|
const { t } = useTranslation()
|
||||||
const [dimensions, setDimensions] = useState({ width: 0, height: 0 })
|
const [dimensions, setDimensions] = useState({ width: 0, height: 0 })
|
||||||
const { width } = dimensions
|
const { width } = dimensions
|
||||||
@@ -91,16 +91,16 @@ const TorrentCache = ({ cache, isMini }) => {
|
|||||||
ctx.strokeRect(0, 0, pieceSize, pieceSize)
|
ctx.strokeRect(0, 0, pieceSize, pieceSize)
|
||||||
ctx.setTransform(1, 0, 0, 1, 0, 0)
|
ctx.setTransform(1, 0, 0, 1, 0, 0)
|
||||||
|
|
||||||
if (priority > 0) {
|
if (!isMini && isSnakeDebugMode && priority > 0) {
|
||||||
let info = ''
|
let info = ''
|
||||||
if (priority === 1) info = '*'
|
if (priority === 1) info = '*'
|
||||||
else if (priority === 2) info = 'H'
|
else if (priority === 2) info = 'H'
|
||||||
else if (priority === 3) info = 'R'
|
else if (priority === 3) info = 'R'
|
||||||
else if (priority === 4) info = 'N'
|
else if (priority === 4) info = 'N'
|
||||||
else if (priority === 5) info = 'A'
|
else if (priority === 5) info = 'A'
|
||||||
ctx.font = isMini ? '12px monospace' : '10px monospace'
|
ctx.font = '10px monospace'
|
||||||
const xpad = isMini ? pieceSize * 0.34 : pieceSize * 0.28
|
const xpad = pieceSize * 0.28
|
||||||
const ypad = isMini ? pieceSize * 0.69 : pieceSize * 0.78
|
const ypad = pieceSize * 0.78
|
||||||
ctx.fillStyle = 'black'
|
ctx.fillStyle = 'black'
|
||||||
ctx.fillText(info, x + xpad, y + ypad)
|
ctx.fillText(info, x + xpad, y + ypad)
|
||||||
}
|
}
|
||||||
@@ -123,6 +123,7 @@ const TorrentCache = ({ cache, isMini }) => {
|
|||||||
rangeColor,
|
rangeColor,
|
||||||
isMini,
|
isMini,
|
||||||
theme,
|
theme,
|
||||||
|
isSnakeDebugMode,
|
||||||
])
|
])
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
|||||||
@@ -33,6 +33,7 @@
|
|||||||
"CopyHash": "Copy Hash",
|
"CopyHash": "Copy Hash",
|
||||||
"CopyLink": "Copy link",
|
"CopyLink": "Copy link",
|
||||||
"Data": "Data",
|
"Data": "Data",
|
||||||
|
"DebugMode": "Debug mode",
|
||||||
"Delete": "Delete",
|
"Delete": "Delete",
|
||||||
"DeleteTorrent?": "Delete Torrent?",
|
"DeleteTorrent?": "Delete Torrent?",
|
||||||
"DeleteTorrents?": "Delete All Torrents?",
|
"DeleteTorrents?": "Delete All Torrents?",
|
||||||
|
|||||||
@@ -33,6 +33,7 @@
|
|||||||
"CopyHash": "Скопировать хеш",
|
"CopyHash": "Скопировать хеш",
|
||||||
"CopyLink": "Копировать",
|
"CopyLink": "Копировать",
|
||||||
"Data": "Данные",
|
"Data": "Данные",
|
||||||
|
"DebugMode": "Режим отладки",
|
||||||
"Delete": "Удалить",
|
"Delete": "Удалить",
|
||||||
"DeleteTorrent?": "Удалить торрент?",
|
"DeleteTorrent?": "Удалить торрент?",
|
||||||
"DeleteTorrents?": "Удалить все торренты?",
|
"DeleteTorrents?": "Удалить все торренты?",
|
||||||
|
|||||||
Reference in New Issue
Block a user