Upload App.tsx
Browse files- src/App.tsx +206 -148
src/App.tsx
CHANGED
|
@@ -1062,6 +1062,33 @@ function InfoModal({ file, onClose, initialShowEncode }: { file: FileEntry; onCl
|
|
| 1062 |
);
|
| 1063 |
}
|
| 1064 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1065 |
// ─── Trim Modal ───────────────────────────────────────────────────────────────
|
| 1066 |
function TrimModal({ file, onClose, onTrimStarted }: {
|
| 1067 |
file: FileEntry;
|
|
@@ -1741,7 +1768,7 @@ function FolderRow({ folder, fileCount, isOpen, onToggle, onRename, onDelete, on
|
|
| 1741 |
}
|
| 1742 |
|
| 1743 |
// ─── File Row ─────────────────────────────────────────────────────────────────
|
| 1744 |
-
function FileRow({ f, selected, onToggle, onInfo, onShowSettings, onTrim, onEncode, onUnzip, onPixeldrain, onCopyLink, onRename, onMove, onDelete, infoFileId, trimFileId, unzipping, allFolders }: {
|
| 1745 |
f: FileEntry;
|
| 1746 |
selected: boolean;
|
| 1747 |
onToggle: () => void;
|
|
@@ -1752,6 +1779,7 @@ function FileRow({ f, selected, onToggle, onInfo, onShowSettings, onTrim, onEnco
|
|
| 1752 |
onUnzip: () => void;
|
| 1753 |
onPixeldrain: () => void;
|
| 1754 |
onCopyLink: () => void;
|
|
|
|
| 1755 |
onRename: () => void;
|
| 1756 |
onMove: () => void;
|
| 1757 |
onDelete: () => void;
|
|
@@ -1808,6 +1836,14 @@ function FileRow({ f, selected, onToggle, onInfo, onShowSettings, onTrim, onEnco
|
|
| 1808 |
)}
|
| 1809 |
|
| 1810 |
{/* Trim — only for media files */}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1811 |
{media && (
|
| 1812 |
<IconBtn title="Trim" onClick={onTrim} active={trimFileId === f.id}>
|
| 1813 |
<svg className="h-3.5 w-3.5" fill="none" viewBox="0 0 24 24" stroke="currentColor" strokeWidth={2}>
|
|
@@ -1883,6 +1919,7 @@ function FileList({ files, onRefresh, onSelectForEncode, onJobStarted, onBatchEn
|
|
| 1883 |
const [trimFile, setTrimFile] = useState<FileEntry | null>(null);
|
| 1884 |
const [moveFile, setMoveFile] = useState<FileEntry | null>(null);
|
| 1885 |
const [toast, setToast] = useState<string | null>(null);
|
|
|
|
| 1886 |
const [pdJobs, setPdJobs] = useState<Record<string, string>>({});
|
| 1887 |
const [mergeFiles, setMergeFiles] = useState<FileEntry[] | null>(null);
|
| 1888 |
const [unzippingId, setUnzippingId] = useState<string | null>(null);
|
|
@@ -2026,6 +2063,13 @@ function FileList({ files, onRefresh, onSelectForEncode, onJobStarted, onBatchEn
|
|
| 2026 |
))}
|
| 2027 |
</div>
|
| 2028 |
)}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 2029 |
|
| 2030 |
{selected.size > 0 && (
|
| 2031 |
<BatchBar
|
|
@@ -2138,6 +2182,7 @@ function FileList({ files, onRefresh, onSelectForEncode, onJobStarted, onBatchEn
|
|
| 2138 |
unzipping={unzippingId === f.id}
|
| 2139 |
onPixeldrain={() => handlePixeldrain(f)}
|
| 2140 |
onCopyLink={() => handleCopyLink(f)}
|
|
|
|
| 2141 |
onRename={() => startRename(f)}
|
| 2142 |
onMove={() => setMoveFile(f)}
|
| 2143 |
onDelete={() => handleDelete(f)}
|
|
@@ -3467,6 +3512,8 @@ function RemoteTab({
|
|
| 3467 |
const [selected, setSelected] = useState<Set<string>>(new Set());
|
| 3468 |
const [downloadJobs, setDownloadJobs] = useState<string[]>([]);
|
| 3469 |
const [toast, setToast] = useState<string | null>(null);
|
|
|
|
|
|
|
| 3470 |
const [renamingName, setRenamingName] = useState<string | null>(null);
|
| 3471 |
const [renameVal, setRenameVal] = useState("");
|
| 3472 |
const [deleting, setDeleting] = useState<string | null>(null);
|
|
@@ -3687,165 +3734,176 @@ function RemoteTab({
|
|
| 3687 |
</section>
|
| 3688 |
|
| 3689 |
{downloadJobs.length > 0 && (
|
| 3690 |
-
|
| 3691 |
-
|
| 3692 |
-
|
| 3693 |
-
|
| 3694 |
-
|
| 3695 |
-
|
| 3696 |
-
|
| 3697 |
-
|
| 3698 |
-
|
| 3699 |
-
|
| 3700 |
-
|
| 3701 |
-
)}
|
| 3702 |
-
|
| 3703 |
-
{/* Batch actions bar */}
|
| 3704 |
-
{selected.size > 0 && (
|
| 3705 |
-
<div className="flex flex-wrap items-center gap-2 rounded-xl border border-violet-200 bg-violet-50 px-4 py-3 shadow-sm">
|
| 3706 |
-
<span className="flex h-6 w-6 items-center justify-center rounded-full bg-violet-600 text-[11px] font-bold text-white">{selected.size}</span>
|
| 3707 |
-
<span className="text-sm font-semibold text-violet-800">selected</span>
|
| 3708 |
-
<button onClick={() => setSelected(new Set())} className="ml-1 rounded-full p-0.5 text-violet-400 hover:text-violet-700">
|
| 3709 |
-
<svg className="h-4 w-4" fill="none" viewBox="0 0 24 24" stroke="currentColor" strokeWidth={2}>
|
| 3710 |
-
<path strokeLinecap="round" strokeLinejoin="round" d="M6 18 18 6M6 6l12 12" />
|
| 3711 |
-
</svg>
|
| 3712 |
-
</button>
|
| 3713 |
-
<div className="flex-1" />
|
| 3714 |
-
{selectedFiles.length > 0 && (
|
| 3715 |
-
<button onClick={handleBatchDownload}
|
| 3716 |
-
className="flex items-center gap-1.5 rounded-lg bg-sky-500 px-3 py-1.5 text-xs font-semibold text-white hover:bg-sky-600 transition-colors">
|
| 3717 |
-
⬇ Download ({selectedFiles.length})
|
| 3718 |
-
</button>
|
| 3719 |
-
)}
|
| 3720 |
-
{selectedDirs.length > 0 && selectedFiles.length === 0 && (
|
| 3721 |
-
<button onClick={handleBatchDownload}
|
| 3722 |
-
className="flex items-center gap-1.5 rounded-lg bg-amber-500 px-3 py-1.5 text-xs font-semibold text-white hover:bg-amber-600 transition-colors">
|
| 3723 |
-
📁 Download ({selectedDirs.length})
|
| 3724 |
-
</button>
|
| 3725 |
)}
|
| 3726 |
-
<button onClick={handleBatchDelete}
|
| 3727 |
-
className="flex items-center gap-1.5 rounded-lg bg-red-500 px-3 py-1.5 text-xs font-semibold text-white hover:bg-red-600 transition-colors">
|
| 3728 |
-
🗑 Delete ({selected.size})
|
| 3729 |
-
</button>
|
| 3730 |
-
</div>
|
| 3731 |
-
)}
|
| 3732 |
|
| 3733 |
-
|
| 3734 |
-
|
| 3735 |
-
|
| 3736 |
-
|
| 3737 |
-
|
| 3738 |
-
|
| 3739 |
-
|
| 3740 |
-
<>
|
| 3741 |
-
|
| 3742 |
-
|
| 3743 |
-
|
| 3744 |
-
|
| 3745 |
-
|
| 3746 |
-
|
| 3747 |
-
|
| 3748 |
-
<>⬆ Upload to Remote</>
|
| 3749 |
)}
|
| 3750 |
-
|
| 3751 |
-
|
| 3752 |
-
|
| 3753 |
-
|
| 3754 |
-
<
|
| 3755 |
-
|
| 3756 |
-
|
| 3757 |
-
|
| 3758 |
-
|
| 3759 |
-
|
| 3760 |
-
|
| 3761 |
-
|
| 3762 |
-
<svg className="animate-spin h-6 w-6 mx-auto mb-2 text-violet-500" fill="none" viewBox="0 0 24 24">
|
| 3763 |
-
<circle className="opacity-25" cx="12" cy="12" r="10" stroke="currentColor" strokeWidth="4" />
|
| 3764 |
-
<path className="opacity-75" fill="currentColor" d="M4 12a8 8 0 018-8v8H4z" />
|
| 3765 |
-
</svg>
|
| 3766 |
-
Loading remote files…
|
| 3767 |
-
</div>
|
| 3768 |
-
) : error ? (
|
| 3769 |
-
<div className="rounded-xl border border-red-200 bg-red-50 px-4 py-6 text-center">
|
| 3770 |
-
<p className="text-sm font-medium text-red-600">❌ {error}</p>
|
| 3771 |
-
<p className="text-xs text-red-400 mt-1">Check the server URL and try again</p>
|
| 3772 |
-
</div>
|
| 3773 |
-
) : entries.length === 0 ? (
|
| 3774 |
-
<div className="rounded-xl border border-dashed border-slate-200 py-10 text-center text-sm text-slate-400">
|
| 3775 |
-
No files or folders found. Click Connect to load.
|
| 3776 |
-
</div>
|
| 3777 |
-
) : (
|
| 3778 |
-
<div className="rounded-xl border border-slate-200 bg-white overflow-hidden divide-y divide-slate-100">
|
| 3779 |
-
{entries.map((entry) => (
|
| 3780 |
-
<div key={entry.name} className={`flex items-center gap-3 px-4 py-3 transition-colors ${
|
| 3781 |
-
selected.has(entry.name) ? "bg-violet-50" : "hover:bg-slate-50"
|
| 3782 |
-
}`}>
|
| 3783 |
-
<input type="checkbox" className="h-4 w-4 accent-violet-600 rounded flex-shrink-0 cursor-pointer"
|
| 3784 |
-
checked={selected.has(entry.name)} onChange={() => toggleSelect(entry.name)} />
|
| 3785 |
-
|
| 3786 |
-
{renamingName === entry.name ? (
|
| 3787 |
-
<div className="flex-1 flex items-center gap-2">
|
| 3788 |
-
<span className="text-lg flex-shrink-0">{getIcon(entry)}</span>
|
| 3789 |
-
<input autoFocus value={renameVal} onChange={(e) => setRenameVal(e.target.value)}
|
| 3790 |
-
onBlur={() => handleRename(entry.name)}
|
| 3791 |
-
onKeyDown={(e) => {
|
| 3792 |
-
if (e.key === "Enter") handleRename(entry.name);
|
| 3793 |
-
if (e.key === "Escape") setRenamingName(null);
|
| 3794 |
-
}}
|
| 3795 |
-
className="flex-1 rounded border border-violet-400 px-2 py-0.5 text-sm focus:outline-none focus:ring-2 focus:ring-violet-100" />
|
| 3796 |
-
</div>
|
| 3797 |
-
) : (
|
| 3798 |
-
<button onClick={() => entry.isDir ? toggleSelect(entry.name) : toggleSelect(entry.name)}
|
| 3799 |
-
className="flex items-center gap-3 flex-1 min-w-0 text-left">
|
| 3800 |
-
<span className="text-lg flex-shrink-0">{getIcon(entry)}</span>
|
| 3801 |
-
<div className="flex-1 min-w-0">
|
| 3802 |
-
<p className={`truncate text-sm font-medium ${entry.isDir ? "text-amber-700" : "text-slate-800"}`}>
|
| 3803 |
-
{entry.name}{entry.isDir ? "/" : ""}
|
| 3804 |
-
</p>
|
| 3805 |
-
{entry.sizeStr && <p className="text-xs text-slate-400 mt-0.5">{entry.sizeStr}</p>}
|
| 3806 |
-
</div>
|
| 3807 |
-
</button>
|
| 3808 |
-
)}
|
| 3809 |
-
|
| 3810 |
-
<div className="flex items-center gap-0.5 flex-shrink-0">
|
| 3811 |
-
{/* Rename */}
|
| 3812 |
-
<IconBtn title="Rename" onClick={() => { setRenamingName(entry.name); setRenameVal(entry.name); }}>
|
| 3813 |
-
<svg className="h-3.5 w-3.5" fill="none" viewBox="0 0 24 24" stroke="currentColor" strokeWidth={2}>
|
| 3814 |
-
<path strokeLinecap="round" strokeLinejoin="round" d="m16.862 4.487 1.687-1.688a1.875 1.875 0 1 1 2.652 2.652L10.582 16.07a4.5 4.5 0 0 1-1.897 1.13L6 18l.8-2.685a4.5 4.5 0 0 1 1.13-1.897l8.932-8.931Zm0 0L19.5 7.125" />
|
| 3815 |
-
</svg>
|
| 3816 |
-
</IconBtn>
|
| 3817 |
-
|
| 3818 |
-
{/* Download to local */}
|
| 3819 |
-
{!entry.isDir && (
|
| 3820 |
-
<IconBtn title="Download to local" onClick={() => handleDownload(entry)}>
|
| 3821 |
-
<svg className="h-3.5 w-3.5" fill="none" viewBox="0 0 24 24" stroke="currentColor" strokeWidth={2}>
|
| 3822 |
-
<path strokeLinecap="round" strokeLinejoin="round" d="M3 16.5v2.25A2.25 2.25 0 0 0 5.25 21h13.5A2.25 2.25 0 0 0 21 18.75V16.5M16.5 12 12 16.5m0 0L7.5 12m4.5 4.5V3" />
|
| 3823 |
-
</svg>
|
| 3824 |
-
</IconBtn>
|
| 3825 |
-
)}
|
| 3826 |
|
| 3827 |
-
|
| 3828 |
-
|
| 3829 |
-
|
| 3830 |
-
|
| 3831 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 3832 |
<circle className="opacity-25" cx="12" cy="12" r="10" stroke="currentColor" strokeWidth="4" />
|
| 3833 |
<path className="opacity-75" fill="currentColor" d="M4 12a8 8 0 018-8v8H4z" />
|
| 3834 |
</svg>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 3835 |
) : (
|
| 3836 |
-
<
|
| 3837 |
-
|
| 3838 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 3839 |
)}
|
| 3840 |
-
|
| 3841 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 3842 |
</div>
|
| 3843 |
-
)
|
| 3844 |
-
</
|
| 3845 |
-
)}
|
| 3846 |
-
</section>
|
| 3847 |
</>
|
| 3848 |
)}
|
|
|
|
|
|
|
|
|
|
| 3849 |
</div>
|
| 3850 |
);
|
| 3851 |
}
|
|
|
|
| 1062 |
);
|
| 1063 |
}
|
| 1064 |
|
| 1065 |
+
function PreviewModal({ title, url, onClose }: { title: string; url: string; onClose: () => void }) {
|
| 1066 |
+
return (
|
| 1067 |
+
<div className="fixed inset-0 z-50 flex items-center justify-center p-4 bg-black/50 backdrop-blur-sm" onClick={onClose}>
|
| 1068 |
+
<div className="w-full max-w-4xl rounded-3xl bg-slate-950 shadow-2xl overflow-hidden" onClick={(e) => e.stopPropagation()}>
|
| 1069 |
+
<div className="flex items-center justify-between gap-3 px-5 py-4 border-b border-slate-800 bg-slate-900">
|
| 1070 |
+
<div className="min-w-0">
|
| 1071 |
+
<p className="text-sm font-semibold text-white truncate">Preview: {title}</p>
|
| 1072 |
+
<p className="text-xs text-slate-400">Video playback uses the browser's media player.</p>
|
| 1073 |
+
</div>
|
| 1074 |
+
<button onClick={onClose} className="rounded-lg p-1.5 text-slate-400 hover:bg-slate-800 hover:text-white transition-colors">
|
| 1075 |
+
<svg className="h-4 w-4" fill="none" viewBox="0 0 24 24" stroke="currentColor" strokeWidth={2}>
|
| 1076 |
+
<path strokeLinecap="round" strokeLinejoin="round" d="M6 18 18 6M6 6l12 12" />
|
| 1077 |
+
</svg>
|
| 1078 |
+
</button>
|
| 1079 |
+
</div>
|
| 1080 |
+
<div className="bg-black p-4">
|
| 1081 |
+
<video className="w-full max-h-[70vh] rounded-3xl bg-black" controls autoPlay playsInline src={url} />
|
| 1082 |
+
<div className="mt-3 flex flex-wrap items-center justify-between gap-3 text-xs text-slate-400">
|
| 1083 |
+
<p>If playback fails, open the file directly.</p>
|
| 1084 |
+
<a href={url} target="_blank" rel="noreferrer" className="rounded-full bg-slate-800 px-3 py-1 text-slate-200 hover:bg-slate-700 transition-colors">Open raw file</a>
|
| 1085 |
+
</div>
|
| 1086 |
+
</div>
|
| 1087 |
+
</div>
|
| 1088 |
+
</div>
|
| 1089 |
+
);
|
| 1090 |
+
}
|
| 1091 |
+
|
| 1092 |
// ─── Trim Modal ───────────────────────────────────────────────────────────────
|
| 1093 |
function TrimModal({ file, onClose, onTrimStarted }: {
|
| 1094 |
file: FileEntry;
|
|
|
|
| 1768 |
}
|
| 1769 |
|
| 1770 |
// ─── File Row ─────────────────────────────────────────────────────────────────
|
| 1771 |
+
function FileRow({ f, selected, onToggle, onInfo, onShowSettings, onTrim, onEncode, onUnzip, onPixeldrain, onCopyLink, onPlay, onRename, onMove, onDelete, infoFileId, trimFileId, unzipping, allFolders }: {
|
| 1772 |
f: FileEntry;
|
| 1773 |
selected: boolean;
|
| 1774 |
onToggle: () => void;
|
|
|
|
| 1779 |
onUnzip: () => void;
|
| 1780 |
onPixeldrain: () => void;
|
| 1781 |
onCopyLink: () => void;
|
| 1782 |
+
onPlay?: () => void;
|
| 1783 |
onRename: () => void;
|
| 1784 |
onMove: () => void;
|
| 1785 |
onDelete: () => void;
|
|
|
|
| 1836 |
)}
|
| 1837 |
|
| 1838 |
{/* Trim — only for media files */}
|
| 1839 |
+
{media && (
|
| 1840 |
+
<IconBtn title="Play preview" onClick={onPlay || (() => {})}>
|
| 1841 |
+
<svg className="h-3.5 w-3.5" fill="none" viewBox="0 0 24 24" stroke="currentColor" strokeWidth={2}>
|
| 1842 |
+
<path strokeLinecap="round" strokeLinejoin="round" d="M5.25 5.653c0-.856.917-1.398 1.667-.986l11.54 6.347a1.125 1.125 0 0 1 0 1.972l-11.54 6.347a1.125 1.125 0 0 1-1.667-.986V5.653Z" />
|
| 1843 |
+
</svg>
|
| 1844 |
+
</IconBtn>
|
| 1845 |
+
)}
|
| 1846 |
+
|
| 1847 |
{media && (
|
| 1848 |
<IconBtn title="Trim" onClick={onTrim} active={trimFileId === f.id}>
|
| 1849 |
<svg className="h-3.5 w-3.5" fill="none" viewBox="0 0 24 24" stroke="currentColor" strokeWidth={2}>
|
|
|
|
| 1919 |
const [trimFile, setTrimFile] = useState<FileEntry | null>(null);
|
| 1920 |
const [moveFile, setMoveFile] = useState<FileEntry | null>(null);
|
| 1921 |
const [toast, setToast] = useState<string | null>(null);
|
| 1922 |
+
const [previewFile, setPreviewFile] = useState<FileEntry | null>(null);
|
| 1923 |
const [pdJobs, setPdJobs] = useState<Record<string, string>>({});
|
| 1924 |
const [mergeFiles, setMergeFiles] = useState<FileEntry[] | null>(null);
|
| 1925 |
const [unzippingId, setUnzippingId] = useState<string | null>(null);
|
|
|
|
| 2063 |
))}
|
| 2064 |
</div>
|
| 2065 |
)}
|
| 2066 |
+
{previewFile && (
|
| 2067 |
+
<PreviewModal
|
| 2068 |
+
title={previewFile.name}
|
| 2069 |
+
url={`/api/files/${encodeURIComponent(previewFile.id)}/download`}
|
| 2070 |
+
onClose={() => setPreviewFile(null)}
|
| 2071 |
+
/>
|
| 2072 |
+
)}
|
| 2073 |
|
| 2074 |
{selected.size > 0 && (
|
| 2075 |
<BatchBar
|
|
|
|
| 2182 |
unzipping={unzippingId === f.id}
|
| 2183 |
onPixeldrain={() => handlePixeldrain(f)}
|
| 2184 |
onCopyLink={() => handleCopyLink(f)}
|
| 2185 |
+
onPlay={() => setPreviewFile(f)}
|
| 2186 |
onRename={() => startRename(f)}
|
| 2187 |
onMove={() => setMoveFile(f)}
|
| 2188 |
onDelete={() => handleDelete(f)}
|
|
|
|
| 3512 |
const [selected, setSelected] = useState<Set<string>>(new Set());
|
| 3513 |
const [downloadJobs, setDownloadJobs] = useState<string[]>([]);
|
| 3514 |
const [toast, setToast] = useState<string | null>(null);
|
| 3515 |
+
const [previewUrl, setPreviewUrl] = useState<string | null>(null);
|
| 3516 |
+
const [previewTitle, setPreviewTitle] = useState<string>("");
|
| 3517 |
const [renamingName, setRenamingName] = useState<string | null>(null);
|
| 3518 |
const [renameVal, setRenameVal] = useState("");
|
| 3519 |
const [deleting, setDeleting] = useState<string | null>(null);
|
|
|
|
| 3734 |
</section>
|
| 3735 |
|
| 3736 |
{downloadJobs.length > 0 && (
|
| 3737 |
+
<div className="space-y-2">
|
| 3738 |
+
<p className="text-xs font-semibold uppercase tracking-wider text-slate-500">Downloading to local storage</p>
|
| 3739 |
+
{downloadJobs.map((jid) => (
|
| 3740 |
+
<DownloadProgress key={jid} jobId={jid}
|
| 3741 |
+
onDone={() => setToast("✓ File downloaded to local Files tab")} />
|
| 3742 |
+
))}
|
| 3743 |
+
<button onClick={() => setDownloadJobs([])}
|
| 3744 |
+
className="text-xs text-slate-400 hover:text-slate-600 hover:underline">
|
| 3745 |
+
Clear download history
|
| 3746 |
+
</button>
|
| 3747 |
+
</div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 3748 |
)}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 3749 |
|
| 3750 |
+
{selected.size > 0 && (
|
| 3751 |
+
<div className="flex flex-wrap items-center gap-2 rounded-xl border border-violet-200 bg-violet-50 px-4 py-3 shadow-sm">
|
| 3752 |
+
<span className="flex h-6 w-6 items-center justify-center rounded-full bg-violet-600 text-[11px] font-bold text-white">{selected.size}</span>
|
| 3753 |
+
<span className="text-sm font-semibold text-violet-800">selected</span>
|
| 3754 |
+
<button onClick={() => setSelected(new Set())} className="ml-1 rounded-full p-0.5 text-violet-400 hover:text-violet-700">
|
| 3755 |
+
<svg className="h-4 w-4" fill="none" viewBox="0 0 24 24" stroke="currentColor" strokeWidth={2}>
|
| 3756 |
+
<path strokeLinecap="round" strokeLinejoin="round" d="M6 18 18 6M6 6l12 12" />
|
| 3757 |
+
</svg>
|
| 3758 |
+
</button>
|
| 3759 |
+
<div className="flex-1" />
|
| 3760 |
+
{selectedFiles.length > 0 && (
|
| 3761 |
+
<button onClick={handleBatchDownload}
|
| 3762 |
+
className="flex items-center gap-1.5 rounded-lg bg-sky-500 px-3 py-1.5 text-xs font-semibold text-white hover:bg-sky-600 transition-colors">
|
| 3763 |
+
⬇ Download ({selectedFiles.length})
|
| 3764 |
+
</button>
|
|
|
|
| 3765 |
)}
|
| 3766 |
+
{selectedDirs.length > 0 && selectedFiles.length === 0 && (
|
| 3767 |
+
<button onClick={handleBatchDownload}
|
| 3768 |
+
className="flex items-center gap-1.5 rounded-lg bg-amber-500 px-3 py-1.5 text-xs font-semibold text-white hover:bg-amber-600 transition-colors">
|
| 3769 |
+
📁 Download ({selectedDirs.length})
|
| 3770 |
+
</button>
|
| 3771 |
+
)}
|
| 3772 |
+
<button onClick={handleBatchDelete}
|
| 3773 |
+
className="flex items-center gap-1.5 rounded-lg bg-red-500 px-3 py-1.5 text-xs font-semibold text-white hover:bg-red-600 transition-colors">
|
| 3774 |
+
🗑 Delete ({selected.size})
|
| 3775 |
+
</button>
|
| 3776 |
+
</div>
|
| 3777 |
+
)}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 3778 |
|
| 3779 |
+
<section>
|
| 3780 |
+
<div className="flex items-center justify-between mb-3">
|
| 3781 |
+
<h2 className="text-sm font-semibold uppercase tracking-widest text-slate-500">Remote Files</h2>
|
| 3782 |
+
<div className="flex items-center gap-2">
|
| 3783 |
+
<button onClick={() => uploadRef.current?.click()} disabled={uploading}
|
| 3784 |
+
className="flex items-center gap-1.5 rounded-lg border border-violet-300 bg-violet-50 px-3 py-1.5 text-xs font-semibold text-violet-700 hover:bg-violet-100 disabled:opacity-50 transition-colors">
|
| 3785 |
+
{uploading ? (
|
| 3786 |
+
<>
|
| 3787 |
+
<svg className="animate-spin h-3 w-3" fill="none" viewBox="0 0 24 24">
|
| 3788 |
<circle className="opacity-25" cx="12" cy="12" r="10" stroke="currentColor" strokeWidth="4" />
|
| 3789 |
<path className="opacity-75" fill="currentColor" d="M4 12a8 8 0 018-8v8H4z" />
|
| 3790 |
</svg>
|
| 3791 |
+
Uploading…
|
| 3792 |
+
</>
|
| 3793 |
+
) : (
|
| 3794 |
+
<>⬆ Upload to Remote</>
|
| 3795 |
+
)}
|
| 3796 |
+
</button>
|
| 3797 |
+
<button onClick={refresh}
|
| 3798 |
+
className="rounded-lg border border-slate-200 bg-white p-1.5 text-slate-500 hover:bg-slate-50" title="Refresh">
|
| 3799 |
+
<svg className="h-4 w-4" fill="none" viewBox="0 0 24 24" stroke="currentColor" strokeWidth={2}>
|
| 3800 |
+
<path strokeLinecap="round" strokeLinejoin="round" d="M16.023 9.348h4.992v-.001M2.985 19.644v-4.992m0 0h4.992m-4.993 0 3.181 3.183a8.25 8.25 0 0 0 13.803-3.7M4.031 9.865a8.25 8.25 0 0 1 13.803-3.7l3.181 3.182m0-4.991v4.99" />
|
| 3801 |
+
</svg>
|
| 3802 |
+
</button>
|
| 3803 |
+
</div>
|
| 3804 |
+
</div>
|
| 3805 |
+
|
| 3806 |
+
{loading ? (
|
| 3807 |
+
<div className="py-10 text-center text-sm text-slate-400">
|
| 3808 |
+
<svg className="animate-spin h-6 w-6 mx-auto mb-2 text-violet-500" fill="none" viewBox="0 0 24 24">
|
| 3809 |
+
<circle className="opacity-25" cx="12" cy="12" r="10" stroke="currentColor" strokeWidth="4" />
|
| 3810 |
+
<path className="opacity-75" fill="currentColor" d="M4 12a8 8 0 018-8v8H4z" />
|
| 3811 |
+
</svg>
|
| 3812 |
+
Loading remote files…
|
| 3813 |
+
</div>
|
| 3814 |
+
) : error ? (
|
| 3815 |
+
<div className="rounded-xl border border-red-200 bg-red-50 px-4 py-6 text-center">
|
| 3816 |
+
<p className="text-sm font-medium text-red-600">❌ {error}</p>
|
| 3817 |
+
<p className="text-xs text-red-400 mt-1">Check the server URL and try again</p>
|
| 3818 |
+
</div>
|
| 3819 |
+
) : entries.length === 0 ? (
|
| 3820 |
+
<div className="rounded-xl border border-dashed border-slate-200 py-10 text-center text-sm text-slate-400">
|
| 3821 |
+
No files or folders found. Click Connect to load.
|
| 3822 |
+
</div>
|
| 3823 |
+
) : (
|
| 3824 |
+
<div className="rounded-xl border border-slate-200 bg-white overflow-hidden divide-y divide-slate-100">
|
| 3825 |
+
{entries.map((entry) => (
|
| 3826 |
+
<div key={entry.name} className={`flex items-center gap-3 px-4 py-3 transition-colors ${
|
| 3827 |
+
selected.has(entry.name) ? "bg-violet-50" : "hover:bg-slate-50"
|
| 3828 |
+
}`}>
|
| 3829 |
+
<input type="checkbox" className="h-4 w-4 accent-violet-600 rounded flex-shrink-0 cursor-pointer"
|
| 3830 |
+
checked={selected.has(entry.name)} onChange={() => toggleSelect(entry.name)} />
|
| 3831 |
+
|
| 3832 |
+
{renamingName === entry.name ? (
|
| 3833 |
+
<div className="flex-1 flex items-center gap-2">
|
| 3834 |
+
<span className="text-lg flex-shrink-0">{getIcon(entry)}</span>
|
| 3835 |
+
<input autoFocus value={renameVal} onChange={(e) => setRenameVal(e.target.value)}
|
| 3836 |
+
onBlur={() => handleRename(entry.name)}
|
| 3837 |
+
onKeyDown={(e) => {
|
| 3838 |
+
if (e.key === "Enter") handleRename(entry.name);
|
| 3839 |
+
if (e.key === "Escape") setRenamingName(null);
|
| 3840 |
+
}}
|
| 3841 |
+
className="flex-1 rounded border border-violet-400 px-2 py-0.5 text-sm focus:outline-none focus:ring-2 focus:ring-violet-100" />
|
| 3842 |
+
</div>
|
| 3843 |
) : (
|
| 3844 |
+
<button onClick={() => toggleSelect(entry.name)}
|
| 3845 |
+
className="flex items-center gap-3 flex-1 min-w-0 text-left">
|
| 3846 |
+
<span className="text-lg flex-shrink-0">{getIcon(entry)}</span>
|
| 3847 |
+
<div className="flex-1 min-w-0">
|
| 3848 |
+
<p className={`truncate text-sm font-medium ${entry.isDir ? "text-amber-700" : "text-slate-800"}`}>
|
| 3849 |
+
{entry.name}{entry.isDir ? "/" : ""}
|
| 3850 |
+
</p>
|
| 3851 |
+
{entry.sizeStr && <p className="text-xs text-slate-400 mt-0.5">{entry.sizeStr}</p>}
|
| 3852 |
+
</div>
|
| 3853 |
+
</button>
|
| 3854 |
)}
|
| 3855 |
+
|
| 3856 |
+
<div className="flex items-center gap-0.5 flex-shrink-0">
|
| 3857 |
+
<IconBtn title="Rename" onClick={() => { setRenamingName(entry.name); setRenameVal(entry.name); }}>
|
| 3858 |
+
<svg className="h-3.5 w-3.5" fill="none" viewBox="0 0 24 24" stroke="currentColor" strokeWidth={2}>
|
| 3859 |
+
<path strokeLinecap="round" strokeLinejoin="round" d="m16.862 4.487 1.687-1.688a1.875 1.875 0 1 1 2.652 2.652L10.582 16.07a4.5 4.5 0 0 1-1.897 1.13L6 18l.8-2.685a4.5 4.5 0 0 1 1.13-1.897l8.932-8.931Zm0 0L19.5 7.125" />
|
| 3860 |
+
</svg>
|
| 3861 |
+
</IconBtn>
|
| 3862 |
+
|
| 3863 |
+
{!entry.isDir && isMediaFile(entry.name) && (
|
| 3864 |
+
<IconBtn title="Play preview" onClick={() => {
|
| 3865 |
+
const base = serverUrl.trim().replace(/\/+$/, "");
|
| 3866 |
+
setPreviewUrl(`${base}/${encodeURIComponent(entry.name)}`);
|
| 3867 |
+
setPreviewTitle(entry.name);
|
| 3868 |
+
}}>
|
| 3869 |
+
<svg className="h-3.5 w-3.5" fill="none" viewBox="0 0 24 24" stroke="currentColor" strokeWidth={2}>
|
| 3870 |
+
<path strokeLinecap="round" strokeLinejoin="round" d="M5.25 5.653c0-.856.917-1.398 1.667-.986l11.54 6.347a1.125 1.125 0 0 1 0 1.972l-11.54 6.347a1.125 1.125 0 0 1-1.667-.986V5.653Z" />
|
| 3871 |
+
</svg>
|
| 3872 |
+
</IconBtn>
|
| 3873 |
+
)}
|
| 3874 |
+
|
| 3875 |
+
{!entry.isDir && (
|
| 3876 |
+
<IconBtn title="Download to local" onClick={() => handleDownload(entry)}>
|
| 3877 |
+
<svg className="h-3.5 w-3.5" fill="none" viewBox="0 0 24 24" stroke="currentColor" strokeWidth={2}>
|
| 3878 |
+
<path strokeLinecap="round" strokeLinejoin="round" d="M3 16.5v2.25A2.25 2.25 0 0 0 5.25 21h13.5A2.25 2.25 0 0 0 21 18.75V16.5M16.5 12 12 16.5m0 0L7.5 12m4.5 4.5V3" />
|
| 3879 |
+
</svg>
|
| 3880 |
+
</IconBtn>
|
| 3881 |
+
)}
|
| 3882 |
+
|
| 3883 |
+
<IconBtn title="Delete from remote" onClick={() => handleDelete(entry.name)} danger
|
| 3884 |
+
disabled={deleting === entry.name}>
|
| 3885 |
+
{deleting === entry.name ? (
|
| 3886 |
+
<svg className="animate-spin h-3.5 w-3.5" fill="none" viewBox="0 0 24 24">
|
| 3887 |
+
<circle className="opacity-25" cx="12" cy="12" r="10" stroke="currentColor" strokeWidth="4" />
|
| 3888 |
+
<path className="opacity-75" fill="currentColor" d="M4 12a8 8 0 018-8v8H4z" />
|
| 3889 |
+
</svg>
|
| 3890 |
+
) : (
|
| 3891 |
+
<svg className="h-3.5 w-3.5" fill="none" viewBox="0 0 24 24" stroke="currentColor" strokeWidth={2}>
|
| 3892 |
+
<path strokeLinecap="round" strokeLinejoin="round" d="m14.74 9-.346 9m-4.788 0L9.26 9m9.968-3.21c.342.052.682.107 1.022.166m-1.022-.165L18.16 19.673a2.25 2.25 0 0 1-2.244 2.077H8.084a2.25 2.25 0 0 1-2.244-2.077L4.772 5.79m14.456 0a48.108 48.108 0 0 0-3.478-.397m-12 .562c.34-.059.68-.114 1.022-.165m0 0a48.11 48.11 0 0 1 3.478-.397m7.5 0v-.916c0-1.18-.91-2.164-2.09-2.201a51.964 51.964 0 0 0-3.32 0c-1.18.037-2.09 1.022-2.09 2.201v.916m7.5 0a48.667 48.667 0 0 0-7.5 0" />
|
| 3893 |
+
</svg>
|
| 3894 |
+
)}
|
| 3895 |
+
</IconBtn>
|
| 3896 |
+
</div>
|
| 3897 |
+
</div>
|
| 3898 |
+
))}
|
| 3899 |
</div>
|
| 3900 |
+
)}
|
| 3901 |
+
</section>
|
|
|
|
|
|
|
| 3902 |
</>
|
| 3903 |
)}
|
| 3904 |
+
{previewUrl && (
|
| 3905 |
+
<PreviewModal title={previewTitle} url={previewUrl} onClose={() => setPreviewUrl(null)} />
|
| 3906 |
+
)}
|
| 3907 |
</div>
|
| 3908 |
);
|
| 3909 |
}
|