new changes
This commit is contained in:
@@ -12,6 +12,10 @@ interface FtpAccount {
|
||||
|
||||
export function FtpPage() {
|
||||
const [accounts, setAccounts] = useState<FtpAccount[]>([])
|
||||
const [logPath, setLogPath] = useState<string | null>(null)
|
||||
const [logContent, setLogContent] = useState('')
|
||||
const [logLoading, setLogLoading] = useState(false)
|
||||
const [logError, setLogError] = useState('')
|
||||
const [loading, setLoading] = useState(true)
|
||||
const [error, setError] = useState('')
|
||||
const [showCreate, setShowCreate] = useState(false)
|
||||
@@ -32,6 +36,18 @@ export function FtpPage() {
|
||||
loadAccounts()
|
||||
}, [])
|
||||
|
||||
const loadFtpLogs = () => {
|
||||
setLogLoading(true)
|
||||
setLogError('')
|
||||
apiRequest<{ path: string | null; content: string }>('/ftp/logs?lines=400')
|
||||
.then((r) => {
|
||||
setLogPath(r.path)
|
||||
setLogContent(r.content || '')
|
||||
})
|
||||
.catch((err) => setLogError(err.message))
|
||||
.finally(() => setLogLoading(false))
|
||||
}
|
||||
|
||||
const handleCreate = (e: React.FormEvent<HTMLFormElement>) => {
|
||||
e.preventDefault()
|
||||
const form = e.currentTarget
|
||||
@@ -119,6 +135,33 @@ export function FtpPage() {
|
||||
<code>apt install pure-ftpd pure-ftpd-common</code>
|
||||
</div>
|
||||
|
||||
<div className="card shadow-sm border-0 mb-4">
|
||||
<div className="card-header d-flex flex-wrap align-items-center justify-content-between gap-2">
|
||||
<span>FTP log (tail)</span>
|
||||
<button type="button" className="btn btn-sm btn-outline-primary" disabled={logLoading} onClick={loadFtpLogs}>
|
||||
{logLoading ? 'Loading…' : logContent ? 'Refresh' : 'Load log'}
|
||||
</button>
|
||||
</div>
|
||||
<div className="card-body">
|
||||
{logError ? <AdminAlert variant="danger">{logError}</AdminAlert> : null}
|
||||
{logPath ? (
|
||||
<p className="small text-muted mb-2">
|
||||
Source: <code className="user-select-all">{logPath}</code>
|
||||
</p>
|
||||
) : null}
|
||||
{logContent ? (
|
||||
<pre
|
||||
className="small bg-body-secondary border rounded p-3 mb-0 text-body"
|
||||
style={{ maxHeight: '22rem', overflow: 'auto', whiteSpace: 'pre-wrap' }}
|
||||
>
|
||||
{logContent}
|
||||
</pre>
|
||||
) : !logLoading && !logError ? (
|
||||
<p className="text-muted small mb-0">Click "Load log" to tail common Pure-FTPd paths on this server.</p>
|
||||
) : null}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<Modal show={showCreate} onHide={() => setShowCreate(false)} centered>
|
||||
<Modal.Header closeButton>
|
||||
<Modal.Title>Create FTP Account</Modal.Title>
|
||||
|
||||
Reference in New Issue
Block a user