fix: reorganize video upload dashboard
This commit is contained in:
parent
0a7c195692
commit
e201fe0135
1 changed files with 105 additions and 108 deletions
|
|
@ -2280,12 +2280,117 @@ export default function App() {
|
|||
Добавить ролик
|
||||
</Button>
|
||||
</form>
|
||||
<section
|
||||
className={`local-video-upload rounded-md border border-dashed p-3 transition-colors ${
|
||||
localVideoDragActive ? "border-primary bg-primary/5" : "border-border bg-background"
|
||||
}`}
|
||||
onDragEnter={(event) => {
|
||||
event.preventDefault()
|
||||
if (localVideoUpload?.status !== "uploading") setLocalVideoDragActive(true)
|
||||
}}
|
||||
onDragOver={(event) => {
|
||||
event.preventDefault()
|
||||
event.dataTransfer.dropEffect = "copy"
|
||||
if (localVideoUpload?.status !== "uploading") setLocalVideoDragActive(true)
|
||||
}}
|
||||
onDragLeave={(event) => {
|
||||
if (event.currentTarget.contains(event.relatedTarget as Node)) return
|
||||
setLocalVideoDragActive(false)
|
||||
}}
|
||||
onDrop={(event) => {
|
||||
event.preventDefault()
|
||||
setLocalVideoDragActive(false)
|
||||
if (localVideoUpload?.status === "uploading") return
|
||||
selectLocalVideo(event.dataTransfer.files?.[0])
|
||||
}}
|
||||
>
|
||||
<input
|
||||
ref={localVideoInputRef}
|
||||
className="hidden"
|
||||
type="file"
|
||||
accept="video/mp4,video/webm,video/quicktime,video/x-matroska,.mp4,.webm,.mov,.mkv"
|
||||
onChange={(event) => {
|
||||
const file = event.currentTarget.files?.[0]
|
||||
event.currentTarget.value = ""
|
||||
selectLocalVideo(file)
|
||||
}}
|
||||
/>
|
||||
<div className="flex flex-wrap items-center gap-3">
|
||||
<span className="flex size-9 shrink-0 items-center justify-center rounded-md bg-muted text-muted-foreground">
|
||||
<Upload className="size-4" />
|
||||
</span>
|
||||
<div className="min-w-0 flex-1">
|
||||
<p className="text-sm font-semibold">Загрузить видео с компьютера</p>
|
||||
<p className="mt-0.5 text-xs text-muted-foreground">MP4, WebM, MOV или MKV. Перетащите файл сюда или выберите его.</p>
|
||||
</div>
|
||||
<Button size="sm" variant="outline" disabled={localVideoUpload?.status === "uploading"} onClick={() => localVideoInputRef.current?.click()}>
|
||||
<Upload data-icon="inline-start" />
|
||||
Выбрать файл
|
||||
</Button>
|
||||
</div>
|
||||
{localVideoUpload ? (
|
||||
<div className="mt-3 border-t pt-3" aria-live="polite">
|
||||
<div className="flex items-start justify-between gap-3">
|
||||
<div className="min-w-0">
|
||||
<p className="truncate text-sm font-medium" title={localVideoUpload.name}>{localVideoUpload.name}</p>
|
||||
<p className={`mt-0.5 text-xs ${localVideoUpload.status === "error" ? "text-destructive" : "text-muted-foreground"}`}>
|
||||
{localVideoUpload.status === "uploading"
|
||||
? `Загружено ${formatFileSize(localVideoUpload.loaded)} из ${formatFileSize(localVideoUpload.total)}`
|
||||
: localVideoUpload.status === "complete"
|
||||
? `Загружено ${formatFileSize(localVideoUpload.total)}. Файл готов к обработке.`
|
||||
: localVideoUpload.status === "cancelled"
|
||||
? "Загрузка отменена."
|
||||
: localVideoUpload.errorMessage || "Не удалось загрузить файл."}
|
||||
</p>
|
||||
</div>
|
||||
{localVideoUpload.status === "uploading" ? (
|
||||
<Button size="icon" variant="outline" title="Отменить загрузку" aria-label="Отменить загрузку" onClick={cancelLocalVideoUpload}>
|
||||
<X className="size-4" />
|
||||
</Button>
|
||||
) : (
|
||||
<Button size="icon" variant="ghost" title="Скрыть статус" aria-label="Скрыть статус" onClick={() => setLocalVideoUpload(null)}>
|
||||
<X className="size-4" />
|
||||
</Button>
|
||||
)}
|
||||
</div>
|
||||
<div className="mt-2 flex items-center gap-3">
|
||||
<div className="h-1.5 flex-1 overflow-hidden rounded-full bg-muted">
|
||||
<div
|
||||
className={localVideoUpload.status === "error" ? "h-full rounded-full bg-destructive transition-all" : "h-full rounded-full bg-primary transition-all"}
|
||||
style={{ width: `${localVideoUpload.status === "complete" ? 100 : localUploadPercent}%` }}
|
||||
/>
|
||||
</div>
|
||||
<span className="w-10 text-right text-xs tabular-nums text-muted-foreground">
|
||||
{localVideoUpload.status === "uploading" ? `${localUploadPercent}%` : localVideoUpload.status === "complete" ? "100%" : ""}
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
) : null}
|
||||
</section>
|
||||
</div>
|
||||
) : null}
|
||||
|
||||
{activeView === "settings" ? (
|
||||
<SettingsPanel onBack={() => setActiveView("dashboard")} onSaved={handleSettingsSaved} />
|
||||
) : <>
|
||||
<section className={`video-storage-strip rounded-md border bg-background p-3 ${videoStorageLow ? "border-amber-300 bg-amber-50/60" : "border-border"}`} aria-live="polite">
|
||||
<div className="flex items-center justify-between gap-2">
|
||||
<p className="text-xs font-semibold uppercase tracking-wide text-muted-foreground">Видео на диске</p>
|
||||
{videoStorage ? <span className="text-xs tabular-nums text-muted-foreground">{videoStoragePercent}%</span> : null}
|
||||
</div>
|
||||
{videoStorage ? (
|
||||
<>
|
||||
<div className="mt-3 h-1.5 overflow-hidden rounded-full bg-muted">
|
||||
<div className={`h-full rounded-full transition-all ${videoStorageLow ? "bg-amber-500" : "bg-primary"}`} style={{ width: `${videoStoragePercent}%` }} />
|
||||
</div>
|
||||
<p className={`mt-2 text-xs leading-5 ${videoStorageLow ? "text-amber-800" : "text-muted-foreground"}`}>
|
||||
Свободно {formatFileSize(videoStorage.freeBytes)} из {formatFileSize(videoStorage.totalBytes)}
|
||||
</p>
|
||||
</>
|
||||
) : (
|
||||
<p className="mt-3 text-xs leading-5 text-muted-foreground">Данные о диске недоступны.</p>
|
||||
)}
|
||||
</section>
|
||||
<section className="workspace-grid grid gap-5 xl:grid-cols-2">
|
||||
<Card className="work-column min-w-0">
|
||||
<CardHeader>
|
||||
|
|
@ -2297,114 +2402,6 @@ export default function App() {
|
|||
</div>
|
||||
</CardHeader>
|
||||
<CardContent className="work-list flex max-h-[72vh] flex-col gap-2 overflow-y-auto">
|
||||
<div className="grid gap-2 xl:grid-cols-[minmax(0,1fr)_13rem]">
|
||||
<section
|
||||
className={`local-video-upload rounded-md border border-dashed p-3 transition-colors ${
|
||||
localVideoDragActive ? "border-primary bg-primary/5" : "border-border bg-background"
|
||||
}`}
|
||||
onDragEnter={(event) => {
|
||||
event.preventDefault()
|
||||
if (localVideoUpload?.status !== "uploading") setLocalVideoDragActive(true)
|
||||
}}
|
||||
onDragOver={(event) => {
|
||||
event.preventDefault()
|
||||
event.dataTransfer.dropEffect = "copy"
|
||||
if (localVideoUpload?.status !== "uploading") setLocalVideoDragActive(true)
|
||||
}}
|
||||
onDragLeave={(event) => {
|
||||
if (event.currentTarget.contains(event.relatedTarget as Node)) return
|
||||
setLocalVideoDragActive(false)
|
||||
}}
|
||||
onDrop={(event) => {
|
||||
event.preventDefault()
|
||||
setLocalVideoDragActive(false)
|
||||
if (localVideoUpload?.status === "uploading") return
|
||||
selectLocalVideo(event.dataTransfer.files?.[0])
|
||||
}}
|
||||
>
|
||||
<input
|
||||
ref={localVideoInputRef}
|
||||
className="hidden"
|
||||
type="file"
|
||||
accept="video/mp4,video/webm,video/quicktime,video/x-matroska,.mp4,.webm,.mov,.mkv"
|
||||
onChange={(event) => {
|
||||
const file = event.currentTarget.files?.[0]
|
||||
event.currentTarget.value = ""
|
||||
selectLocalVideo(file)
|
||||
}}
|
||||
/>
|
||||
<div className="flex flex-wrap items-center gap-3">
|
||||
<span className="flex size-9 shrink-0 items-center justify-center rounded-md bg-muted text-muted-foreground">
|
||||
<Upload className="size-4" />
|
||||
</span>
|
||||
<div className="min-w-0 flex-1">
|
||||
<p className="text-sm font-semibold">Загрузить видео с компьютера</p>
|
||||
<p className="mt-0.5 text-xs text-muted-foreground">MP4, WebM, MOV или MKV. Перетащите файл сюда или выберите его.</p>
|
||||
</div>
|
||||
<Button size="sm" variant="outline" disabled={localVideoUpload?.status === "uploading"} onClick={() => localVideoInputRef.current?.click()}>
|
||||
<Upload data-icon="inline-start" />
|
||||
Выбрать файл
|
||||
</Button>
|
||||
</div>
|
||||
{localVideoUpload ? (
|
||||
<div className="mt-3 border-t pt-3" aria-live="polite">
|
||||
<div className="flex items-start justify-between gap-3">
|
||||
<div className="min-w-0">
|
||||
<p className="truncate text-sm font-medium" title={localVideoUpload.name}>{localVideoUpload.name}</p>
|
||||
<p className={`mt-0.5 text-xs ${localVideoUpload.status === "error" ? "text-destructive" : "text-muted-foreground"}`}>
|
||||
{localVideoUpload.status === "uploading"
|
||||
? `Загружено ${formatFileSize(localVideoUpload.loaded)} из ${formatFileSize(localVideoUpload.total)}`
|
||||
: localVideoUpload.status === "complete"
|
||||
? `Загружено ${formatFileSize(localVideoUpload.total)}. Файл готов к обработке.`
|
||||
: localVideoUpload.status === "cancelled"
|
||||
? "Загрузка отменена."
|
||||
: localVideoUpload.errorMessage || "Не удалось загрузить файл."}
|
||||
</p>
|
||||
</div>
|
||||
{localVideoUpload.status === "uploading" ? (
|
||||
<Button size="icon" variant="outline" title="Отменить загрузку" aria-label="Отменить загрузку" onClick={cancelLocalVideoUpload}>
|
||||
<X className="size-4" />
|
||||
</Button>
|
||||
) : (
|
||||
<Button size="icon" variant="ghost" title="Скрыть статус" aria-label="Скрыть статус" onClick={() => setLocalVideoUpload(null)}>
|
||||
<X className="size-4" />
|
||||
</Button>
|
||||
)}
|
||||
</div>
|
||||
<div className="mt-2 flex items-center gap-3">
|
||||
<div className="h-1.5 flex-1 overflow-hidden rounded-full bg-muted">
|
||||
<div
|
||||
className={localVideoUpload.status === "error" ? "h-full rounded-full bg-destructive transition-all" : "h-full rounded-full bg-primary transition-all"}
|
||||
style={{ width: `${localVideoUpload.status === "complete" ? 100 : localUploadPercent}%` }}
|
||||
/>
|
||||
</div>
|
||||
<span className="w-10 text-right text-xs tabular-nums text-muted-foreground">
|
||||
{localVideoUpload.status === "uploading" ? `${localUploadPercent}%` : localVideoUpload.status === "complete" ? "100%" : ""}
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
) : null}
|
||||
</section>
|
||||
|
||||
<section className={`rounded-md border bg-background p-3 ${videoStorageLow ? "border-amber-300 bg-amber-50/60" : "border-border"}`} aria-live="polite">
|
||||
<div className="flex items-center justify-between gap-2">
|
||||
<p className="text-xs font-semibold uppercase tracking-wide text-muted-foreground">Видео на диске</p>
|
||||
{videoStorage ? <span className="text-xs tabular-nums text-muted-foreground">{videoStoragePercent}%</span> : null}
|
||||
</div>
|
||||
{videoStorage ? (
|
||||
<>
|
||||
<div className="mt-3 h-1.5 overflow-hidden rounded-full bg-muted">
|
||||
<div className={`h-full rounded-full transition-all ${videoStorageLow ? "bg-amber-500" : "bg-primary"}`} style={{ width: `${videoStoragePercent}%` }} />
|
||||
</div>
|
||||
<p className={`mt-2 text-xs leading-5 ${videoStorageLow ? "text-amber-800" : "text-muted-foreground"}`}>
|
||||
Свободно {formatFileSize(videoStorage.freeBytes)} из {formatFileSize(videoStorage.totalBytes)}
|
||||
</p>
|
||||
</>
|
||||
) : (
|
||||
<p className="mt-3 text-xs leading-5 text-muted-foreground">Данные о диске недоступны.</p>
|
||||
)}
|
||||
</section>
|
||||
</div>
|
||||
{productionVideos.length > 0 ? (
|
||||
productionVideos.map((video) => {
|
||||
const draftArticles = video.articles?.filter((article) => article.status !== "published") ?? []
|
||||
|
|
|
|||
Loading…
Reference in a new issue