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 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 KeyInput from './components/KeyInput';
|
||||||
import MediaInput from './components/MediaInput';
|
import MediaInput from './components/MediaInput';
|
||||||
import ResultCard from './components/ResultCard';
|
import ResultCard from './components/ResultCard';
|
||||||
import SubtitleModal from './components/SubtitleModal';
|
|
||||||
import ProcessingAnimation from './components/ProcessingAnimation';
|
import ProcessingAnimation from './components/ProcessingAnimation';
|
||||||
// import Gallery from './components/Gallery';
|
// import Gallery from './components/Gallery';
|
||||||
import ThumbnailStudio from './components/ThumbnailStudio';
|
import ThumbnailStudio from './components/ThumbnailStudio';
|
||||||
|
|
@ -19,7 +18,6 @@ import AdvancedBanner from './components/AdvancedBanner';
|
||||||
import HistoryTab from './components/HistoryTab';
|
import HistoryTab from './components/HistoryTab';
|
||||||
import ProfileMenu from './components/ProfileMenu';
|
import ProfileMenu from './components/ProfileMenu';
|
||||||
import Modal from './components/ui/Modal';
|
import Modal from './components/ui/Modal';
|
||||||
import { getApiUrl } from './config';
|
|
||||||
import { useAuth } from './contexts/AuthContext';
|
import { useAuth } from './contexts/AuthContext';
|
||||||
import { apiFetch, apiJson, QuotaError } from './lib/api';
|
import { apiFetch, apiJson, QuotaError } from './lib/api';
|
||||||
|
|
||||||
|
|
@ -183,8 +181,8 @@ function App() {
|
||||||
const [jobId, setJobId] = useState(null);
|
const [jobId, setJobId] = useState(null);
|
||||||
const [status, setStatus] = useState('idle'); // idle, processing, complete, error
|
const [status, setStatus] = useState('idle'); // idle, processing, complete, error
|
||||||
const [results, setResults] = useState(null);
|
const [results, setResults] = useState(null);
|
||||||
// Bulk subtitles: apply one style to every clip of the job
|
// Bulk subtitles: apply one style to every clip of the job (triggered from
|
||||||
const [showBulkSubtitles, setShowBulkSubtitles] = useState(false);
|
// within a clip's subtitle modal via "apply to all").
|
||||||
const [bulkSub, setBulkSub] = useState({ running: false, current: 0, total: 0, errors: 0 });
|
const [bulkSub, setBulkSub] = useState({ running: false, current: 0, total: 0, errors: 0 });
|
||||||
const [downloadingAll, setDownloadingAll] = useState(false);
|
const [downloadingAll, setDownloadingAll] = useState(false);
|
||||||
const [logs, setLogs] = useState([]);
|
const [logs, setLogs] = useState([]);
|
||||||
|
|
@ -253,7 +251,6 @@ function App() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
setBulkSub({ running: false, current: total, total, errors });
|
setBulkSub({ running: false, current: total, total, errors });
|
||||||
setShowBulkSubtitles(false);
|
|
||||||
// Refresh results so each ResultCard picks up its new subtitled video_url.
|
// Refresh results so each ResultCard picks up its new subtitled video_url.
|
||||||
try {
|
try {
|
||||||
const data = await pollJob(jobId);
|
const data = await pollJob(jobId);
|
||||||
|
|
@ -1212,18 +1209,6 @@ function App() {
|
||||||
)}
|
)}
|
||||||
{results?.clips?.length > 0 && status === 'complete' && (
|
{results?.clips?.length > 0 && status === 'complete' && (
|
||||||
<div className="flex items-center gap-2 ml-auto">
|
<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
|
<button
|
||||||
onClick={handleDownloadAll}
|
onClick={handleDownloadAll}
|
||||||
disabled={downloadingAll}
|
disabled={downloadingAll}
|
||||||
|
|
@ -1264,6 +1249,9 @@ function App() {
|
||||||
isManaged={isManaged}
|
isManaged={isManaged}
|
||||||
onPlay={(time) => handleClipPlay(time)}
|
onPlay={(time) => handleClipPlay(time)}
|
||||||
onPause={handleClipPause}
|
onPause={handleClipPause}
|
||||||
|
onBulkSubtitle={handleBulkSubtitles}
|
||||||
|
clipCount={results.clips.length}
|
||||||
|
bulkProgress={bulkSub}
|
||||||
/>
|
/>
|
||||||
))}
|
))}
|
||||||
</div>
|
</div>
|
||||||
|
|
@ -1392,19 +1380,6 @@ function App() {
|
||||||
isManaged={isManaged}
|
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)} />}
|
{showLogin && <LoginModal onClose={() => setShowLogin(false)} />}
|
||||||
{showTopUp && (
|
{showTopUp && (
|
||||||
|
|
|
||||||
|
|
@ -23,7 +23,7 @@ function formatDuration(clip) {
|
||||||
return `${String(Math.floor(secs / 60)).padStart(2, '0')}:${String(secs % 60).padStart(2, '0')}`;
|
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 [showModal, setShowModal] = useState(false);
|
||||||
const [showSubtitleModal, setShowSubtitleModal] = useState(false);
|
const [showSubtitleModal, setShowSubtitleModal] = useState(false);
|
||||||
const videoRef = React.useRef(null);
|
const videoRef = React.useRef(null);
|
||||||
|
|
@ -747,7 +747,13 @@ export default function ResultCard({ clip, index, jobId, durableUrl, uploadPostK
|
||||||
isOpen={showSubtitleModal}
|
isOpen={showSubtitleModal}
|
||||||
onClose={() => setShowSubtitleModal(false)}
|
onClose={() => setShowSubtitleModal(false)}
|
||||||
onGenerate={handleSubtitle}
|
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}
|
videoUrl={originalVideoUrl}
|
||||||
jobId={jobId}
|
jobId={jobId}
|
||||||
clipIndex={index}
|
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-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)]'}`;
|
: '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 [position, setPosition] = useState('bottom');
|
||||||
const [fontSize] = useState(24);
|
const [fontSize] = useState(24);
|
||||||
const [fontName, setFontName] = useState('Verdana');
|
const [fontName, setFontName] = useState('Verdana');
|
||||||
|
|
@ -479,24 +479,45 @@ export default function SubtitleModal({ isOpen, onClose, onGenerate, isProcessin
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div className="flex gap-2 mt-5 shrink-0">
|
<div className="mt-5 shrink-0 space-y-2">
|
||||||
<button onClick={onClose} className="btn-ghost">
|
{(() => {
|
||||||
cancel
|
const styleOptions = {
|
||||||
</button>
|
|
||||||
<button
|
|
||||||
onClick={() => onGenerate({
|
|
||||||
position, fontSize, fontName, fontColor, borderColor, borderWidth, bgColor, bgOpacity,
|
position, fontSize, fontName, fontColor, borderColor, borderWidth, bgColor, bgOpacity,
|
||||||
// Karaoke burn (server-side ASS render)
|
// Karaoke burn (server-side ASS render)
|
||||||
style, effect, baseOpacity, uppercase, highlightColor,
|
style, effect, baseOpacity, uppercase, highlightColor,
|
||||||
// Remotion data
|
// Remotion data
|
||||||
remotion: useRemotionPreview ? subtitleConfig : null,
|
remotion: useRemotionPreview ? subtitleConfig : null,
|
||||||
})}
|
};
|
||||||
disabled={isProcessing}
|
const bulkRunning = bulkProgress?.running;
|
||||||
className="btn-primary flex-1"
|
return (
|
||||||
>
|
<>
|
||||||
{isProcessing && <Loader2 size={16} className="animate-spin text-brassink" />}
|
<div className="flex gap-2">
|
||||||
{isProcessing ? 'generating...' : (bulkCount > 1 ? `apply to ${bulkCount} clips` : 'apply subtitles')}
|
<button onClick={onClose} className="btn-ghost">
|
||||||
</button>
|
cancel
|
||||||
|
</button>
|
||||||
|
<button
|
||||||
|
onClick={() => onGenerate(styleOptions)}
|
||||||
|
disabled={isProcessing}
|
||||||
|
className="btn-primary flex-1"
|
||||||
|
>
|
||||||
|
{(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>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue