Add Gitea repo sync for credentials (admtracksteel/Keys)

This commit is contained in:
Marcos
2026-03-22 16:29:55 -03:00
parent 22af78e6a5
commit 0084577a70
3 changed files with 182 additions and 15 deletions

View File

@@ -800,10 +800,17 @@
<div class="card">
<div style="margin-bottom: 1rem; padding: 0.75rem; background: var(--bg-input); border-radius: 8px; font-size: 0.85rem;">
<strong>Status:</strong> <span id="orchestrator-status">Carregando...</span>
<button type="button" class="btn" style="margin-left: 1rem; padding: 0.4rem 0.75rem; font-size: 0.75rem;" onclick="syncCredentials()">
<button type="button" class="btn" style="margin-left: 0.5rem; padding: 0.4rem 0.75rem; font-size: 0.75rem;" onclick="syncFromRepo()">
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" width="14" height="14"><path d="M23 4v6h-6M1 20v-6h6"/><path d="M3.51 9a9 9 0 0 1 14.85-3.36L23 10M1 14l4.64 4.36A9 9 0 0 0 20.49 15"/></svg>
Sync Credenciais
Sync Repo
</button>
<button type="button" class="btn" style="margin-left: 0.5rem; padding: 0.4rem 0.75rem; font-size: 0.75rem;" onclick="syncCredentials()">
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" width="14" height="14"><path d="M3 6h18M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6m3 0V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2"/></svg>
Sync Local
</button>
</div>
<div style="margin-bottom: 1rem; padding: 0.5rem 0.75rem; background: var(--success); opacity: 0.15; border-radius: 6px; font-size: 0.75rem;">
<strong>Repo Gitea:</strong> <span id="repo-status">Carregando...</span>
</div>
<div class="config-grid">
@@ -1220,12 +1227,40 @@
if (statusEl) {
statusEl.innerHTML = '<strong>Planner:</strong> ' + data.planner.name + ' | <strong>Executor:</strong> ' + data.executor.name + ' | <strong>Ferramentas:</strong> ' + data.available_tools;
}
// Repo status
const repoEl = document.getElementById('repo-status');
if (repoEl) {
const creds = data.credentials || {};
const giteaRepo = creds.gitea_repo || {};
if (giteaRepo.available) {
repoEl.innerHTML = '<span style="color: var(--success);">✅ Online</span> - ' + giteaRepo.services_count + ' serviço(s) disponível(is)';
} else {
repoEl.innerHTML = '<span style="color: var(--text-muted);">⏳ Sincronizando...</span>';
}
}
} catch (e) {
const statusEl = document.getElementById('orchestrator-status');
if (statusEl) statusEl.textContent = 'Erro ao carregar';
}
}
async function syncFromRepo() {
try {
const res = await apiFetch('/api/sync-from-repo', { method: 'POST' });
const data = await res.json();
if (data.status === 'synced') {
showToast('Repo sincronizado! ' + data.services_count + ' serviços carregados');
} else {
showToast('Erro ao sincronizar repo: ' + data.status, true);
}
loadOrchestratorStatus();
loadCredentials();
} catch (e) {
showToast('Erro ao sincronizar repo.', true);
}
}
async function loadLLMModels() {
try {
const res = await apiFetch('/api/llm-models');