Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ Open http://localhost:8080 and sign in with:

- Local username/password sessions; first admin bootstrapped from env when the DB is empty
- Users see only their torrents; admins can switch **View as** another user
- Access your torrent files over FTPS and from the file list in a torrent's detail panel (read-only for members, read-write for admins)
- Access your torrent files over FTPS and from the file list in a torrent's detail panel (read-only for members; admins can also rename and delete)
- Add torrents via `.torrent` upload, one or several files at a time (per-file errors are reported without blocking the rest)
- Progress / status / peers / downloaded / uploaded with pause, resume, delete
- Completed torrents keep seeding until paused or deleted
Expand Down
52 changes: 13 additions & 39 deletions web/src/FileManager.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -54,46 +54,20 @@ export function FileManager({ torrentId }: { torrentId: number }) {
<section className="file-manager">
<h3>Files</h3>

<nav className="fm-crumbs" aria-label="Path">
<button type="button" onClick={() => void load('/')}>
/
</button>
{crumbs.map((c, i) => (
<span key={i}>
<button type="button" onClick={() => void load('/' + crumbs.slice(0, i + 1).join('/'))}>
{c}
</button>
{i < crumbs.length - 1 ? ' / ' : ''}
</span>
))}
</nav>

{writable ? (
<div className="detail-actions fm-actions">
<label className="button fm-upload">
Upload
<input
type="file"
multiple
disabled={busy}
onChange={(e) => {
const picked = Array.from(e.target.files ?? [])
e.target.value = ''
if (picked.length) void run(() => api.uploadFiles(torrentId, dir, picked))
}}
/>
</label>
<button
type="button"
disabled={busy}
onClick={() => {
const name = prompt('Folder name')?.trim()
if (name) void run(() => api.mkdir(torrentId, join(dir, name)))
}}
>
New folder
{dir !== '/' ? (
<nav className="fm-crumbs" aria-label="Path">
<button type="button" onClick={() => void load('/')}>
/
</button>
</div>
{crumbs.map((c, i) => (
<span key={i}>
<button type="button" onClick={() => void load('/' + crumbs.slice(0, i + 1).join('/'))}>
{c}
</button>
{i < crumbs.length - 1 ? ' / ' : ''}
</span>
))}
</nav>
) : null}

{error ? <p className="error">{error}</p> : null}
Expand Down
13 changes: 0 additions & 13 deletions web/src/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -188,19 +188,6 @@ export const api = {
request<FileListing>(`/api/torrents/${torrentId}/files?${fileQuery(path)}`),
fileDownloadUrl: (torrentId: number, path: string) =>
`/api/torrents/${torrentId}/files/download?${fileQuery(path)}`,
uploadFiles: (torrentId: number, dir: string, files: File[]) => {
const fd = new FormData()
for (const f of files) fd.append('files', f)
return request<{ uploaded: number }>(`/api/torrents/${torrentId}/files/upload?${fileQuery(dir)}`, {
method: 'POST',
body: fd,
})
},
mkdir: (torrentId: number, path: string) =>
request<{ status: string }>(`/api/torrents/${torrentId}/files/mkdir`, {
method: 'POST',
body: JSON.stringify({ path }),
}),
renameFile: (torrentId: number, from: string, to: string) =>
request<{ status: string }>(`/api/torrents/${torrentId}/files/rename`, {
method: 'POST',
Expand Down
Loading