refactor(ui): move 'apply to all' into the subtitle modal itself
Instead of a separate header button + bulk modal, the per-clip subtitle editor now has a second action: 'apply this style to all N clips'. Same bulk loop, but you pick and preview the look on the clip you opened, then one click applies it everywhere (progress shown inline). Header keeps only 'download all' + 'schedule week'.
This commit is contained in:
parent
82dcd0af89
commit
f683dc66df
3 changed files with 49 additions and 47 deletions
|
|
@ -1,9 +1,8 @@
|
|||
import React, { useState, useEffect } from 'react';
|
||||
import { Upload, Sparkles, Youtube, Instagram, Share2, ChevronDown, Check, Activity, LayoutDashboard, Settings, Plus, History, X, Terminal, Shield, LayoutGrid, Image, Globe, RotateCcw, Calendar, AlertTriangle, KeyRound, Bot, Users, Smartphone, ExternalLink, Copy, CheckCircle2, Mail, Loader2, Download, Type } from 'lucide-react';
|
||||
import { Upload, Sparkles, Youtube, Instagram, Share2, ChevronDown, Check, Activity, LayoutDashboard, Settings, Plus, History, X, Terminal, Shield, LayoutGrid, Image, Globe, RotateCcw, Calendar, AlertTriangle, KeyRound, Bot, Users, Smartphone, ExternalLink, Copy, CheckCircle2, Mail, Loader2, Download } from 'lucide-react';
|
||||
import KeyInput from './components/KeyInput';
|
||||
import MediaInput from './components/MediaInput';
|
||||
import ResultCard from './components/ResultCard';
|
||||
import SubtitleModal from './components/SubtitleModal';
|
||||
import ProcessingAnimation from './components/ProcessingAnimation';
|
||||
// import Gallery from './components/Gallery';
|
||||
import ThumbnailStudio from './components/ThumbnailStudio';
|
||||
|
|
@ -19,7 +18,6 @@ import AdvancedBanner from './components/AdvancedBanner';
|
|||
import HistoryTab from './components/HistoryTab';
|
||||
import ProfileMenu from './components/ProfileMenu';
|
||||
import Modal from './components/ui/Modal';
|
||||
import { getApiUrl } from './config';
|
||||
import { useAuth } from './contexts/AuthContext';
|
||||
import { apiFetch, apiJson, QuotaError } from './lib/api';
|
||||
|
||||
|
|
@ -183,8 +181,8 @@ function App() {
|
|||
const [jobId, setJobId] = useState(null);
|
||||
const [status, setStatus] = useState('idle'); // idle, processing, complete, error
|
||||
const [results, setResults] = useState(null);
|
||||
// Bulk subtitles: apply one style to every clip of the job
|
||||
const [showBulkSubtitles, setShowBulkSubtitles] = useState(false);
|
||||
// Bulk subtitles: apply one style to every clip of the job (triggered from
|
||||
// within a clip's subtitle modal via "apply to all").
|
||||
const [bulkSub, setBulkSub] = useState({ running: false, current: 0, total: 0, errors: 0 });
|
||||
const [downloadingAll, setDownloadingAll] = useState(false);
|
||||
const [logs, setLogs] = useState([]);
|
||||
|
|
@ -253,7 +251,6 @@ function App() {
|
|||
}
|
||||
}
|
||||
setBulkSub({ running: false, current: total, total, errors });
|
||||
setShowBulkSubtitles(false);
|
||||
// Refresh results so each ResultCard picks up its new subtitled video_url.
|
||||
try {
|
||||
const data = await pollJob(jobId);
|
||||
|
|
@ -1212,18 +1209,6 @@ function App() {
|
|||
)}
|
||||
{results?.clips?.length > 0 && status === 'complete' && (
|
||||
<div className="flex items-center gap-2 ml-auto">
|
||||
{results.clips.length > 1 && (
|
||||
<button
|
||||
onClick={() => setShowBulkSubtitles(true)}
|
||||
disabled={bulkSub.running}
|
||||
className="btn-ghost px-3 py-2 text-xs"
|
||||
title="Apply one subtitle style to all clips"
|
||||
>
|
||||
{bulkSub.running
|
||||
? <><Loader2 size={14} className="animate-spin" />subtitling {bulkSub.current}/{bulkSub.total}</>
|
||||
: <><Type size={14} />subtitle all</>}
|
||||
</button>
|
||||
)}
|
||||
<button
|
||||
onClick={handleDownloadAll}
|
||||
disabled={downloadingAll}
|
||||
|
|
@ -1264,6 +1249,9 @@ function App() {
|
|||
isManaged={isManaged}
|
||||
onPlay={(time) => handleClipPlay(time)}
|
||||
onPause={handleClipPause}
|
||||
onBulkSubtitle={handleBulkSubtitles}
|
||||
clipCount={results.clips.length}
|
||||
bulkProgress={bulkSub}
|
||||
/>
|
||||
))}
|
||||
</div>
|
||||
|
|
@ -1392,19 +1380,6 @@ function App() {
|
|||
isManaged={isManaged}
|
||||
/>
|
||||
|
||||
{/* Bulk subtitles: preview on the first clip, apply the chosen style to all */}
|
||||
{showBulkSubtitles && results?.clips?.length > 0 && (
|
||||
<SubtitleModal
|
||||
isOpen={showBulkSubtitles}
|
||||
onClose={() => setShowBulkSubtitles(false)}
|
||||
onGenerate={handleBulkSubtitles}
|
||||
isProcessing={bulkSub.running}
|
||||
videoUrl={getApiUrl(results.clips[0].video_url)}
|
||||
jobId={jobId}
|
||||
clipIndex={0}
|
||||
bulkCount={results.clips.length}
|
||||
/>
|
||||
)}
|
||||
|
||||
{showLogin && <LoginModal onClose={() => setShowLogin(false)} />}
|
||||
{showTopUp && (
|
||||
|
|
|
|||
|
|
@ -23,7 +23,7 @@ function formatDuration(clip) {
|
|||
return `${String(Math.floor(secs / 60)).padStart(2, '0')}:${String(secs % 60).padStart(2, '0')}`;
|
||||
}
|
||||
|
||||
export default function ResultCard({ clip, index, jobId, durableUrl, uploadPostKey, uploadUserId, geminiApiKey, elevenLabsKey, isManaged, onPlay, onPause }) {
|
||||
export default function ResultCard({ clip, index, jobId, durableUrl, uploadPostKey, uploadUserId, geminiApiKey, elevenLabsKey, isManaged, onPlay, onPause, onBulkSubtitle, clipCount = 1, bulkProgress }) {
|
||||
const [showModal, setShowModal] = useState(false);
|
||||
const [showSubtitleModal, setShowSubtitleModal] = useState(false);
|
||||
const videoRef = React.useRef(null);
|
||||
|
|
@ -747,7 +747,13 @@ export default function ResultCard({ clip, index, jobId, durableUrl, uploadPostK
|
|||
isOpen={showSubtitleModal}
|
||||
onClose={() => setShowSubtitleModal(false)}
|
||||
onGenerate={handleSubtitle}
|
||||
isProcessing={isSubtitling}
|
||||
onApplyAll={onBulkSubtitle ? async (options) => {
|
||||
await onBulkSubtitle(options);
|
||||
setShowSubtitleModal(false);
|
||||
} : undefined}
|
||||
bulkCount={clipCount}
|
||||
bulkProgress={bulkProgress}
|
||||
isProcessing={isSubtitling || (bulkProgress?.running ?? false)}
|
||||
videoUrl={originalVideoUrl}
|
||||
jobId={jobId}
|
||||
clipIndex={index}
|
||||
|
|
|
|||
|
|
@ -75,7 +75,7 @@ const swatchClass = (selected) =>
|
|||
? 'ring-2 ring-[color:var(--color-accent)] ring-offset-2 ring-offset-[color:var(--color-paper-2)]'
|
||||
: 'ring-1 ring-[color:var(--color-rule-2)] hover:ring-[color:var(--color-accent)]'}`;
|
||||
|
||||
export default function SubtitleModal({ isOpen, onClose, onGenerate, isProcessing, videoUrl, jobId, clipIndex, existingHook, bulkCount = 0 }) {
|
||||
export default function SubtitleModal({ isOpen, onClose, onGenerate, onApplyAll, isProcessing, videoUrl, jobId, clipIndex, existingHook, bulkCount = 0, bulkProgress }) {
|
||||
const [position, setPosition] = useState('bottom');
|
||||
const [fontSize] = useState(24);
|
||||
const [fontName, setFontName] = useState('Verdana');
|
||||
|
|
@ -479,25 +479,46 @@ export default function SubtitleModal({ isOpen, onClose, onGenerate, isProcessin
|
|||
</div>
|
||||
</div>
|
||||
|
||||
<div className="flex gap-2 mt-5 shrink-0">
|
||||
<button onClick={onClose} className="btn-ghost">
|
||||
cancel
|
||||
</button>
|
||||
<button
|
||||
onClick={() => onGenerate({
|
||||
<div className="mt-5 shrink-0 space-y-2">
|
||||
{(() => {
|
||||
const styleOptions = {
|
||||
position, fontSize, fontName, fontColor, borderColor, borderWidth, bgColor, bgOpacity,
|
||||
// Karaoke burn (server-side ASS render)
|
||||
style, effect, baseOpacity, uppercase, highlightColor,
|
||||
// Remotion data
|
||||
remotion: useRemotionPreview ? subtitleConfig : null,
|
||||
})}
|
||||
};
|
||||
const bulkRunning = bulkProgress?.running;
|
||||
return (
|
||||
<>
|
||||
<div className="flex gap-2">
|
||||
<button onClick={onClose} className="btn-ghost">
|
||||
cancel
|
||||
</button>
|
||||
<button
|
||||
onClick={() => onGenerate(styleOptions)}
|
||||
disabled={isProcessing}
|
||||
className="btn-primary flex-1"
|
||||
>
|
||||
{isProcessing && <Loader2 size={16} className="animate-spin text-brassink" />}
|
||||
{isProcessing ? 'generating...' : (bulkCount > 1 ? `apply to ${bulkCount} clips` : 'apply subtitles')}
|
||||
{(isProcessing && !bulkRunning) && <Loader2 size={16} className="animate-spin text-brassink" />}
|
||||
{(isProcessing && !bulkRunning) ? 'generating...' : 'apply to this clip'}
|
||||
</button>
|
||||
</div>
|
||||
{onApplyAll && bulkCount > 1 && (
|
||||
<button
|
||||
onClick={() => onApplyAll(styleOptions)}
|
||||
disabled={isProcessing}
|
||||
className="btn-ghost w-full flex items-center justify-center gap-2"
|
||||
>
|
||||
{bulkRunning
|
||||
? <><Loader2 size={16} className="animate-spin" />applying to all… {bulkProgress.current}/{bulkProgress.total}</>
|
||||
: `apply this style to all ${bulkCount} clips`}
|
||||
</button>
|
||||
)}
|
||||
</>
|
||||
);
|
||||
})()}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</Modal>
|
||||
|
|
|
|||
Loading…
Reference in a new issue