- Dashboard com 5 gráficos Chart.js (execuções, status, custo, agentes, pipelines) - Sistema de notificações com polling, badge e Browser Notification API - Relatórios MD automáticos para execuções de agentes e pipelines (data/reports/) - Lucide local (v0.475.0) com nomes de ícones atualizados e refreshIcons centralizado - Correção de ícones icon-only (padding CSS sobrescrito por btn-sm) - Cards de agentes e pipelines com botões alinhados na base (flex column) - Terminal com busca, download, cópia e auto-scroll toggle - Histórico com export CSV, retry, paginação e truncamento de texto - Webhooks com edição e teste inline - Duplicação de agentes e export/import JSON - Rate limiting, CORS, correlação de requests e health check no backend - Escrita atômica em JSON (temp + rename) e store de notificações - Tema claro/escuro com toggle e persistência em localStorage - Atalhos de teclado 1-9 para navegação entre seções
82 lines
2.4 KiB
JavaScript
82 lines
2.4 KiB
JavaScript
const SettingsUI = {
|
|
async load() {
|
|
try {
|
|
const [settings, info] = await Promise.all([
|
|
API.settings.get(),
|
|
API.system.info(),
|
|
]);
|
|
|
|
SettingsUI.populateForm(settings);
|
|
SettingsUI.populateSystemInfo(info);
|
|
SettingsUI.updateThemeInfo();
|
|
} catch (err) {
|
|
Toast.error(`Erro ao carregar configurações: ${err.message}`);
|
|
}
|
|
},
|
|
|
|
updateThemeInfo() {
|
|
const themeEl = document.getElementById('info-current-theme');
|
|
if (themeEl) {
|
|
const theme = document.documentElement.getAttribute('data-theme') || 'dark';
|
|
themeEl.textContent = theme === 'dark' ? 'Escuro' : 'Claro';
|
|
}
|
|
},
|
|
|
|
populateForm(settings) {
|
|
const fields = {
|
|
'settings-default-model': settings.defaultModel || 'claude-sonnet-4-6',
|
|
'settings-default-workdir': settings.defaultWorkdir || '',
|
|
'settings-max-concurrent': settings.maxConcurrent || 5,
|
|
};
|
|
|
|
for (const [id, value] of Object.entries(fields)) {
|
|
const el = document.getElementById(id);
|
|
if (el) el.value = value;
|
|
}
|
|
},
|
|
|
|
populateSystemInfo(info) {
|
|
const fields = {
|
|
'info-server-version': info.serverVersion || '1.0.0',
|
|
'info-node-version': info.nodeVersion || 'N/A',
|
|
'info-claude-version': info.claudeVersion || 'N/A',
|
|
'info-platform': info.platform || 'N/A',
|
|
'info-uptime': SettingsUI.formatUptime(info.uptime),
|
|
};
|
|
|
|
for (const [id, value] of Object.entries(fields)) {
|
|
const el = document.getElementById(id);
|
|
if (el) el.textContent = value;
|
|
}
|
|
},
|
|
|
|
formatUptime(seconds) {
|
|
if (!seconds && seconds !== 0) return 'N/A';
|
|
const h = Math.floor(seconds / 3600);
|
|
const m = Math.floor((seconds % 3600) / 60);
|
|
const s = seconds % 60;
|
|
const parts = [];
|
|
if (h > 0) parts.push(`${h}h`);
|
|
if (m > 0) parts.push(`${m}m`);
|
|
parts.push(`${s}s`);
|
|
return parts.join(' ');
|
|
},
|
|
|
|
async save() {
|
|
const data = {
|
|
defaultModel: document.getElementById('settings-default-model')?.value || 'claude-sonnet-4-6',
|
|
defaultWorkdir: document.getElementById('settings-default-workdir')?.value.trim() || '',
|
|
maxConcurrent: parseInt(document.getElementById('settings-max-concurrent')?.value) || 5,
|
|
};
|
|
|
|
try {
|
|
await API.settings.save(data);
|
|
Toast.success('Configurações salvas com sucesso');
|
|
} catch (err) {
|
|
Toast.error(`Erro ao salvar configurações: ${err.message}`);
|
|
}
|
|
},
|
|
};
|
|
|
|
window.SettingsUI = SettingsUI;
|