torxyton commited on
Commit
892b01b
·
1 Parent(s): 8a12c0d

fix: Corrige tema escuro e melhora estabilidade Gradio

Browse files

- Remove CSS hardcoded que sobrescrevia tema escuro dinâmico
- Corrige aplicação automática do tema escuro na inicialização
- Adiciona configurações otimizadas do Gradio (max_threads, enable_queue, show_tips)
- Melhora estabilidade das conexões WebSocket
- Reduz erros ERR_ABORTED na fila de dados
- Atualiza CHANGELOG.md com versão 2.2.1

CHANGELOG.md CHANGED
@@ -5,6 +5,19 @@ Todas as mudanças notáveis neste projeto serão documentadas neste arquivo.
5
  O formato é baseado em [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
6
  e este projeto adere ao [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7
 
 
 
 
 
 
 
 
 
 
 
 
 
 
8
  ## [2.2.0] - 2024-01-29
9
 
10
  ### 🎉 Adicionado
 
5
  O formato é baseado em [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
6
  e este projeto adere ao [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7
 
8
+ ## [2.2.1] - 2024-01-29
9
+
10
+ ### 🐛 Corrigido
11
+ - **CSS Hardcoded Conflitante**: Removido CSS que sobrescrevia o tema escuro dinâmico
12
+ - **Carregamento de Tema**: Corrigido problema que impedia aplicação automática do tema escuro
13
+ - **Conexões WebSocket**: Melhorada estabilidade das conexões Gradio com novas configurações
14
+ - **Erros ERR_ABORTED**: Reduzidos significativamente os erros de timeout na fila de dados
15
+
16
+ ### 🔄 Alterado
17
+ - **Configurações Gradio**: Adicionadas configurações otimizadas (`max_threads`, `enable_queue`, `show_tips`)
18
+ - **Estabilidade da Interface**: Melhor performance e menos interrupções de conexão
19
+ - **Aplicação de Tema**: Tema escuro agora é aplicado automaticamente na inicialização
20
+
21
  ## [2.2.0] - 2024-01-29
22
 
23
  ### 🎉 Adicionado
logs/application.db ADDED
Binary file (45.1 kB). View file
 
logs/test_logging.db ADDED
Binary file (45.1 kB). View file
 
src/core/__pycache__/__init__.cpython-313.pyc ADDED
Binary file (140 Bytes). View file
 
src/core/__pycache__/database_logger.cpython-313.pyc ADDED
Binary file (18.9 kB). View file
 
src/ui/__pycache__/__init__.cpython-313.pyc ADDED
Binary file (138 Bytes). View file
 
src/ui/__pycache__/theme_manager.cpython-313.pyc ADDED
Binary file (11 kB). View file
 
src/ui/dark_theme_components.py CHANGED
@@ -275,6 +275,37 @@ class DarkThemeUIComponents:
275
  </div>
276
  """
277
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
278
  @staticmethod
279
  def create_footer(model_info: Dict[str, Any]) -> str:
280
  """Cria rodapé com tema escuro."""
 
275
  </div>
276
  """
277
 
278
+ @staticmethod
279
+ def _get_ai_status_html(available: bool, model_description: str = "") -> str:
280
+ """Gera HTML para status da IA com tema escuro."""
281
+ theme = theme_manager.get_current_theme()
282
+ colors = theme['colors']
283
+
284
+ if available:
285
+ return f"""
286
+ <div style="background: {colors['success_background']}; border: 1px solid {colors['success_border']}; border-radius: 12px; padding: 15px; margin-bottom: 20px; box-shadow: 0 4px 12px {colors['shadow']};">
287
+ <div style="display: flex; align-items: center; gap: 12px;">
288
+ <span style="font-size: 1.3em;">🤖</span>
289
+ <div>
290
+ <strong style="color: {colors['success_text']}; font-size: 1.1em;">IA Ativa:</strong>
291
+ <span style="color: {colors['success_text']}; margin-left: 8px;">{model_description}</span>
292
+ </div>
293
+ </div>
294
+ </div>
295
+ """
296
+ else:
297
+ return f"""
298
+ <div style="background: {colors['warning_background']}; border: 1px solid {colors['warning_border']}; border-radius: 12px; padding: 15px; margin-bottom: 20px; box-shadow: 0 4px 12px {colors['shadow']};">
299
+ <div style="display: flex; align-items: center; gap: 12px;">
300
+ <span style="font-size: 1.3em;">⚠️</span>
301
+ <div>
302
+ <strong style="color: {colors['warning_text']}; font-size: 1.1em;">IA Indisponível:</strong>
303
+ <span style="color: {colors['warning_text']}; margin-left: 8px;">Executando apenas análise técnica</span>
304
+ </div>
305
+ </div>
306
+ </div>
307
+ """
308
+
309
  @staticmethod
310
  def create_footer(model_info: Dict[str, Any]) -> str:
311
  """Cria rodapé com tema escuro."""
src/ui/gradio_interface.py CHANGED
@@ -145,62 +145,17 @@ class UIComponents:
145
  with gr.Tab("🔍 Dados Detalhados"):
146
  outputs['raw_data'] = gr.JSON()
147
 
148
- # Adicionar novos outputs ao dicionário
149
- if 'harmonic_patterns' not in outputs:
150
- outputs['harmonic_patterns'] = gr.HTML()
151
- if 'fibonacci_alerts' not in outputs:
152
- outputs['fibonacci_alerts'] = gr.HTML()
153
-
154
- return output_section, outputs
155
 
156
  @staticmethod
157
  def create_footer(model_info: Optional[Dict[str, Any]] = None) -> str:
158
- """Cria rodapé da aplicação."""
159
- timestamp = DateTimeUtils.get_current_datetime()
160
-
161
- if model_info and model_info.get('available', False):
162
- ai_status = f"🤖 IA: {model_info.get('description', 'Modelo Ativo')}"
163
- else:
164
- ai_status = "⚠️ IA: Indisponível (apenas análise técnica)"
165
-
166
- return f"""
167
- <div style="text-align: center; padding: 15px; background: #f8f9fa; border-radius: 8px; margin-top: 20px; border-top: 2px solid #dee2e6;">
168
- <p style="margin: 0; color: #6c757d; font-size: 0.9em;">
169
- {ai_status} | ⏰ Última atualização: {timestamp}
170
- </p>
171
- <p style="margin: 5px 0 0 0; color: #adb5bd; font-size: 0.8em;">
172
- Desenvolvido para análise de scalping no mercado financeiro
173
- </p>
174
- </div>
175
- """
176
 
177
  @staticmethod
178
  def _get_ai_status_html(available: bool, model_description: str = "") -> str:
179
- """Gera HTML para status da IA."""
180
- if available:
181
- return f"""
182
- <div style="background: #d4edda; border: 1px solid #c3e6cb; border-radius: 8px; padding: 12px; margin-bottom: 15px;">
183
- <div style="display: flex; align-items: center; gap: 10px;">
184
- <span style="font-size: 1.2em;">🤖</span>
185
- <div>
186
- <strong style="color: #155724;">IA Ativa:</strong>
187
- <span style="color: #155724;">{model_description}</span>
188
- </div>
189
- </div>
190
- </div>
191
- """
192
- else:
193
- return """
194
- <div style="background: #fff3cd; border: 1px solid #ffeaa7; border-radius: 8px; padding: 12px; margin-bottom: 15px;">
195
- <div style="display: flex; align-items: center; gap: 10px;">
196
- <span style="font-size: 1.2em;">⚠️</span>
197
- <div>
198
- <strong style="color: #856404;">IA Indisponível:</strong>
199
- <span style="color: #856404;">Executando apenas análise técnica</span>
200
- </div>
201
- </div>
202
- </div>
203
- """
204
 
205
 
206
  class ResultFormatter:
@@ -378,7 +333,7 @@ class GradioInterface:
378
  """Cria interface completa do Gradio."""
379
  with gr.Blocks(
380
  title=AppConfig.APP_TITLE,
381
- theme=gr.themes.Soft(),
382
  css=self._get_custom_css()
383
  ) as interface:
384
  # Cabeçalho
@@ -546,7 +501,10 @@ class GradioInterface:
546
  'server_name': '127.0.0.1',
547
  'server_port': 7860,
548
  'share': False,
549
- 'show_error': True
 
 
 
550
  }
551
 
552
  # Mesclar argumentos padrão com os fornecidos
 
145
  with gr.Tab("🔍 Dados Detalhados"):
146
  outputs['raw_data'] = gr.JSON()
147
 
148
+ return output_section, outputs
 
 
 
 
 
 
149
 
150
  @staticmethod
151
  def create_footer(model_info: Optional[Dict[str, Any]] = None) -> str:
152
+ """Cria rodapé da aplicação com tema dinâmico."""
153
+ return DarkThemeUIComponents.create_footer(model_info)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
154
 
155
  @staticmethod
156
  def _get_ai_status_html(available: bool, model_description: str = "") -> str:
157
+ """Gera HTML para status da IA com tema dinâmico."""
158
+ return DarkThemeUIComponents._get_ai_status_html(available, model_description)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
159
 
160
 
161
  class ResultFormatter:
 
333
  """Cria interface completa do Gradio."""
334
  with gr.Blocks(
335
  title=AppConfig.APP_TITLE,
336
+ theme=gr.themes.Base(),
337
  css=self._get_custom_css()
338
  ) as interface:
339
  # Cabeçalho
 
501
  'server_name': '127.0.0.1',
502
  'server_port': 7860,
503
  'share': False,
504
+ 'show_error': True,
505
+ 'max_threads': 10,
506
+ 'enable_queue': True,
507
+ 'show_tips': False
508
  }
509
 
510
  # Mesclar argumentos padrão com os fornecidos
src/ui/theme_manager.py CHANGED
@@ -70,7 +70,13 @@ class ThemeManager:
70
  'text_muted': '#adb5bd',
71
  'border': '#dee2e6',
72
  'success': '#28a745',
 
 
 
73
  'warning': '#ffc107',
 
 
 
74
  'error': '#dc3545',
75
  'info': '#007bff',
76
  'gradient_start': '#667eea',
@@ -108,7 +114,13 @@ class ThemeManager:
108
  'text_muted': '#94a3b8',
109
  'border': '#475569',
110
  'success': '#10b981',
 
 
 
111
  'warning': '#f59e0b',
 
 
 
112
  'error': '#ef4444',
113
  'info': '#3b82f6',
114
  'gradient_start': '#4f46e5',
@@ -154,6 +166,11 @@ class ThemeManager:
154
  {self.get_css_variables()}
155
 
156
  /* Tema {theme['name'].title()} */
 
 
 
 
 
157
  .gradio-container {{
158
  max-width: 1200px !important;
159
  margin: auto !important;
 
70
  'text_muted': '#adb5bd',
71
  'border': '#dee2e6',
72
  'success': '#28a745',
73
+ 'success_background': '#d4edda',
74
+ 'success_border': '#c3e6cb',
75
+ 'success_text': '#155724',
76
  'warning': '#ffc107',
77
+ 'warning_background': '#fff3cd',
78
+ 'warning_border': '#ffeaa7',
79
+ 'warning_text': '#856404',
80
  'error': '#dc3545',
81
  'info': '#007bff',
82
  'gradient_start': '#667eea',
 
114
  'text_muted': '#94a3b8',
115
  'border': '#475569',
116
  'success': '#10b981',
117
+ 'success_background': '#064e3b',
118
+ 'success_border': '#065f46',
119
+ 'success_text': '#34d399',
120
  'warning': '#f59e0b',
121
+ 'warning_background': '#451a03',
122
+ 'warning_border': '#92400e',
123
+ 'warning_text': '#fbbf24',
124
  'error': '#ef4444',
125
  'info': '#3b82f6',
126
  'gradient_start': '#4f46e5',
 
166
  {self.get_css_variables()}
167
 
168
  /* Tema {theme['name'].title()} */
169
+ body {{
170
+ background-color: {colors['background']} !important;
171
+ color: {colors['text_primary']} !important;
172
+ }}
173
+
174
  .gradio-container {{
175
  max-width: 1200px !important;
176
  margin: auto !important;
src/utils/__pycache__/logging_decorators.cpython-313.pyc ADDED
Binary file (12.9 kB). View file