corrigido o progresso na inteface e o encoder
This commit is contained in:
@@ -45,33 +45,32 @@ def show():
|
||||
log_content = ui.label().style('white-space: pre-wrap; font-family: monospace;')
|
||||
with log_container: log_content.move(log_container)
|
||||
|
||||
# --- COLUNA DA DIREITA: LISTA DE TAREFAS (Igual ao antigo) ---
|
||||
# --- COLUNA DA DIREITA: LISTA DE TAREFAS ---
|
||||
with ui.card().classes('w-full h-[80vh] bg-gray-50 flex flex-col p-0'):
|
||||
# Cabeçalho da Lista
|
||||
with ui.row().classes('w-full p-4 bg-white border-b items-center justify-between'):
|
||||
ui.label('📋 Fila de Processamento').classes('text-lg font-bold text-gray-700')
|
||||
lbl_status_top = ui.label('Ocioso').classes('text-sm text-gray-400')
|
||||
|
||||
# Container da Lista (Onde a mágica acontece)
|
||||
# Container da Lista
|
||||
tasks_container = ui.column().classes('w-full p-2 gap-2 overflow-y-auto flex-grow')
|
||||
|
||||
# --- RENDERIZADOR DA LISTA ---
|
||||
# --- RENDERIZADOR DA LISTA (Com Duas Barras) ---
|
||||
def render_tasks():
|
||||
tasks_container.clear()
|
||||
|
||||
# Se não tiver tarefas
|
||||
if not state.tasks:
|
||||
with tasks_container:
|
||||
ui.label('Nenhuma atividade recente.').classes('text-gray-400 italic p-4')
|
||||
return
|
||||
|
||||
# Itera sobre as tarefas (reversed para mais recentes no topo)
|
||||
for fname, data in reversed(state.tasks.items()):
|
||||
status = data['status']
|
||||
pct = data['progress']
|
||||
global_pct = data['progress']
|
||||
file_pct = data.get('file_progress', 0)
|
||||
speed = data.get('speed', '')
|
||||
label = data['label']
|
||||
|
||||
# Estilo baseado no status (Igual ao seu código antigo)
|
||||
icon = 'circle'; color = 'grey'; spin = False
|
||||
bg_color = 'bg-white'
|
||||
|
||||
@@ -91,35 +90,52 @@ def show():
|
||||
icon = 'block'; color = 'red'
|
||||
|
||||
with tasks_container:
|
||||
with ui.card().classes(f'w-full p-2 {bg_color} flex-row items-center gap-3'):
|
||||
with ui.card().classes(f'w-full p-3 {bg_color} flex-row items-start gap-3'):
|
||||
# Ícone
|
||||
if spin: ui.spinner(size='sm').classes('text-blue-500')
|
||||
else: ui.icon(icon, color=color, size='sm')
|
||||
if spin: ui.spinner(size='sm').classes('text-blue-500 mt-1')
|
||||
else: ui.icon(icon, color=color, size='sm').classes('mt-1')
|
||||
|
||||
# Conteúdo
|
||||
with ui.column().classes('flex-grow gap-0'):
|
||||
ui.label(label).classes('font-bold text-sm text-gray-800 truncate')
|
||||
ui.label(fname).classes('text-xs text-gray-500 truncate')
|
||||
with ui.column().classes('flex-grow gap-1 w-full'):
|
||||
# Título e Nome Arquivo
|
||||
ui.label(label).classes('font-bold text-sm text-gray-800 break-all')
|
||||
ui.label(fname).classes('text-xs text-gray-500 break-all mb-1')
|
||||
|
||||
# Barra de Progresso (Só aparece se estiver rodando)
|
||||
# Se estiver rodando, mostra barras
|
||||
if status == 'running':
|
||||
with ui.row().classes('w-full items-center gap-2 mt-1'):
|
||||
ui.linear_progress(value=pct/100, show_value=False).classes('h-2 rounded flex-grow')
|
||||
ui.label(f"{int(pct)}%").classes('text-xs font-bold text-blue-600')
|
||||
# Barra 1: Global
|
||||
with ui.row().classes('w-full items-center gap-2'):
|
||||
ui.label('Total').classes('text-xs font-bold text-gray-400 w-12')
|
||||
ui.linear_progress(value=global_pct/100, show_value=False).classes('h-2 rounded flex-grow').props('color=blue-4')
|
||||
ui.label(f"{int(global_pct)}%").classes('text-xs font-bold text-blue-400 w-8 text-right')
|
||||
|
||||
# Barra 2: Conversão de Arquivo
|
||||
# Mostra se tivermos algum progresso de arquivo OU velocidade detectada
|
||||
if file_pct > 0 or (speed and speed != "0x"):
|
||||
with ui.row().classes('w-full items-center gap-2'):
|
||||
ui.label('File').classes('text-xs font-bold text-gray-400 w-12')
|
||||
|
||||
# Barra Verde
|
||||
ui.linear_progress(value=file_pct/100, show_value=False).classes('h-3 rounded flex-grow').props('color=green')
|
||||
|
||||
# Porcentagem e Velocidade
|
||||
with ui.row().classes('items-center gap-1'):
|
||||
ui.label(f"{int(file_pct)}%").classes('text-xs font-bold text-green-600')
|
||||
if speed:
|
||||
# Badge de Velocidade
|
||||
ui.label(speed).classes('text-xs bg-green-100 text-green-800 px-1 rounded font-mono')
|
||||
|
||||
# --- LOOP DE ATUALIZAÇÃO ---
|
||||
def update_ui():
|
||||
# 1. Logs
|
||||
# Logs
|
||||
logs = state.get_logs()
|
||||
log_content.set_text("\n".join(logs[-30:]))
|
||||
log_container.scroll_to(percent=1.0)
|
||||
|
||||
# 2. Re-renderiza a lista de tarefas
|
||||
# Nota: O NiceGUI é eficiente, mas para listas muito grandes seria melhor atualizar in-place.
|
||||
# Como limitamos a 20 itens no state, limpar e redesenhar é rápido e seguro.
|
||||
# Tarefas
|
||||
render_tasks()
|
||||
|
||||
# 3. Controles Globais
|
||||
# Status Global
|
||||
if state.watcher and state.watcher.is_running:
|
||||
lbl_status_top.text = "Serviço Rodando"
|
||||
lbl_status_top.classes(replace='text-green-500')
|
||||
@@ -129,10 +145,10 @@ def show():
|
||||
lbl_status_top.classes(replace='text-red-400')
|
||||
switch_run.value = False
|
||||
|
||||
# 4. Botão Cancelar
|
||||
# Botão Cancelar
|
||||
if state.current_file:
|
||||
btn_cancel.classes(remove='hidden')
|
||||
else:
|
||||
btn_cancel.classes(add='hidden')
|
||||
|
||||
ui.timer(1.0, update_ui) # Atualiza a cada 1 segundo
|
||||
ui.timer(1.0, update_ui)
|
||||
Reference in New Issue
Block a user