mirror of
https://github.com/Ernous/TorrServerJellyfin.git
synced 2025-12-21 22:46:09 +05:00
Move wipe to server side. Add UI unsafe buttons (#355)
* move 'remove all' function to server side ('wipe')
* add UnsafeButton to RemoveAll and CloseServer webui
This commit is contained in:
committed by
GitHub
parent
d1b29bd848
commit
5e71af9751
26
web/src/components/UnsafeButton.jsx
Normal file
26
web/src/components/UnsafeButton.jsx
Normal file
@@ -0,0 +1,26 @@
|
||||
import { Button } from '@material-ui/core';
|
||||
import { useEffect, useRef, useState } from 'react';
|
||||
|
||||
export default function UnsafeButton({ timeout, children, disabled, ...props }) {
|
||||
const [timeLeft, setTimeLeft] = useState(timeout || 7)
|
||||
const [buttonDisabled, setButtonDisabled] = useState(disabled || timeLeft > 0)
|
||||
const handleTimerTick = () => {
|
||||
const newTimeLeft = timeLeft - 1
|
||||
setTimeLeft(newTimeLeft)
|
||||
if (newTimeLeft <= 0) {
|
||||
setButtonDisabled(disabled)
|
||||
}
|
||||
}
|
||||
const getTimerText = () => !disabled && timeLeft > 0 ? ` (${timeLeft})` : ''
|
||||
useEffect(() => {
|
||||
if (disabled || !timeLeft) { return }
|
||||
const intervalId = setInterval(handleTimerTick, 1000)
|
||||
return () => clearInterval(intervalId)
|
||||
}, [timeLeft])
|
||||
|
||||
return (
|
||||
<Button disabled={buttonDisabled} {...props}>
|
||||
{children} {getTimerText()}
|
||||
</Button>
|
||||
)
|
||||
}
|
||||
Reference in New Issue
Block a user