Spaces:
Sleeping
Sleeping
Vanderson da Silva Quintino commited on
Commit ·
21f6e1b
1
Parent(s): 35a656e
feat: progress with steps and timer
Browse files
src/ClipForge.Api/wwwroot/index.html
CHANGED
|
@@ -228,8 +228,7 @@
|
|
| 228 |
|
| 229 |
if (res.ok) {
|
| 230 |
status.className = 'status loading';
|
| 231 |
-
|
| 232 |
-
// Fica checando a cada 15s se apareceu vídeo novo
|
| 233 |
startPolling();
|
| 234 |
} else {
|
| 235 |
const err = await res.text();
|
|
@@ -245,8 +244,39 @@
|
|
| 245 |
}
|
| 246 |
|
| 247 |
let pollingInterval = null;
|
|
|
|
| 248 |
let lastVideoCount = 0;
|
| 249 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 250 |
function startPolling() {
|
| 251 |
if (pollingInterval) clearInterval(pollingInterval);
|
| 252 |
pollingInterval = setInterval(async () => {
|
|
@@ -256,14 +286,16 @@
|
|
| 256 |
if (videos.length > lastVideoCount) {
|
| 257 |
lastVideoCount = videos.length;
|
| 258 |
clearInterval(pollingInterval);
|
|
|
|
| 259 |
pollingInterval = null;
|
|
|
|
| 260 |
document.getElementById('status').className = 'status success';
|
| 261 |
document.getElementById('status').textContent = '✅ Vídeo gerado com sucesso!';
|
| 262 |
document.getElementById('generateBtn').disabled = false;
|
| 263 |
loadVideos();
|
| 264 |
}
|
| 265 |
} catch (e) { /* ignore */ }
|
| 266 |
-
},
|
| 267 |
}
|
| 268 |
|
| 269 |
async function loadVideos() {
|
|
|
|
| 228 |
|
| 229 |
if (res.ok) {
|
| 230 |
status.className = 'status loading';
|
| 231 |
+
startProgressAnimation();
|
|
|
|
| 232 |
startPolling();
|
| 233 |
} else {
|
| 234 |
const err = await res.text();
|
|
|
|
| 244 |
}
|
| 245 |
|
| 246 |
let pollingInterval = null;
|
| 247 |
+
let progressInterval = null;
|
| 248 |
let lastVideoCount = 0;
|
| 249 |
|
| 250 |
+
function startProgressAnimation() {
|
| 251 |
+
const status = document.getElementById('status');
|
| 252 |
+
const steps = [
|
| 253 |
+
{ text: '🧠 Gerando ideia viral...', time: 0 },
|
| 254 |
+
{ text: '📝 Escrevendo roteiro com IA...', time: 8 },
|
| 255 |
+
{ text: '🎙️ Gerando narração em português...', time: 15 },
|
| 256 |
+
{ text: '🎬 Baixando clips do YouTube...', time: 25 },
|
| 257 |
+
{ text: '🎬 Baixando mais clips...', time: 60 },
|
| 258 |
+
{ text: '🎞️ Montando vídeo vertical...', time: 120 },
|
| 259 |
+
{ text: '💬 Adicionando legendas...', time: 180 },
|
| 260 |
+
{ text: '✨ Finalizando exportação...', time: 220 },
|
| 261 |
+
{ text: '⏳ Quase lá... processando...', time: 260 }
|
| 262 |
+
];
|
| 263 |
+
|
| 264 |
+
let startTime = Date.now();
|
| 265 |
+
if (progressInterval) clearInterval(progressInterval);
|
| 266 |
+
|
| 267 |
+
progressInterval = setInterval(() => {
|
| 268 |
+
const elapsed = (Date.now() - startTime) / 1000;
|
| 269 |
+
let currentStep = steps[0];
|
| 270 |
+
for (const step of steps) {
|
| 271 |
+
if (elapsed >= step.time) currentStep = step;
|
| 272 |
+
}
|
| 273 |
+
const minutes = Math.floor(elapsed / 60);
|
| 274 |
+
const seconds = Math.floor(elapsed % 60);
|
| 275 |
+
const timeStr = minutes > 0 ? `${minutes}m${seconds}s` : `${seconds}s`;
|
| 276 |
+
status.innerHTML = `<span class="spinner"></span> ${currentStep.text}<br><small style="color:#888">Tempo: ${timeStr} • Pode fechar e voltar depois</small>`;
|
| 277 |
+
}, 1000);
|
| 278 |
+
}
|
| 279 |
+
|
| 280 |
function startPolling() {
|
| 281 |
if (pollingInterval) clearInterval(pollingInterval);
|
| 282 |
pollingInterval = setInterval(async () => {
|
|
|
|
| 286 |
if (videos.length > lastVideoCount) {
|
| 287 |
lastVideoCount = videos.length;
|
| 288 |
clearInterval(pollingInterval);
|
| 289 |
+
clearInterval(progressInterval);
|
| 290 |
pollingInterval = null;
|
| 291 |
+
progressInterval = null;
|
| 292 |
document.getElementById('status').className = 'status success';
|
| 293 |
document.getElementById('status').textContent = '✅ Vídeo gerado com sucesso!';
|
| 294 |
document.getElementById('generateBtn').disabled = false;
|
| 295 |
loadVideos();
|
| 296 |
}
|
| 297 |
} catch (e) { /* ignore */ }
|
| 298 |
+
}, 20000);
|
| 299 |
}
|
| 300 |
|
| 301 |
async function loadVideos() {
|