Actualizar configuracion.html
This commit is contained in:
@@ -1394,6 +1394,40 @@
|
|||||||
} catch(e) { console.error("Error cargando ajustes del robot", e); }
|
} catch(e) { console.error("Error cargando ajustes del robot", e); }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async function saveProviderCreds(event, provider) {
|
||||||
|
event.preventDefault();
|
||||||
|
const btn = event.submitter;
|
||||||
|
const originalText = btn.innerHTML;
|
||||||
|
|
||||||
|
const username = document.getElementById(`user_${provider}`).value;
|
||||||
|
const password = document.getElementById(`pass_${provider}`).value;
|
||||||
|
const auto_dispatch = document.getElementById(`auto_${provider}`).checked;
|
||||||
|
|
||||||
|
btn.disabled = true;
|
||||||
|
btn.innerHTML = '<i data-lucide="loader-2" class="w-4 h-4 animate-spin"></i> Guardando...';
|
||||||
|
lucide.createIcons();
|
||||||
|
|
||||||
|
try {
|
||||||
|
const res = await fetch(`${API_URL}/providers/credentials`, {
|
||||||
|
method: 'POST',
|
||||||
|
headers: { "Content-Type": "application/json", "Authorization": `Bearer ${localStorage.getItem("token")}` },
|
||||||
|
body: JSON.stringify({ provider, username, password, auto_dispatch })
|
||||||
|
});
|
||||||
|
|
||||||
|
if (res.ok) {
|
||||||
|
showToast(`✅ Acceso de ${provider} actualizado`);
|
||||||
|
} else {
|
||||||
|
showToast("❌ Error al guardar acceso", true);
|
||||||
|
}
|
||||||
|
} catch (e) {
|
||||||
|
showToast("❌ Error de red", true);
|
||||||
|
} finally {
|
||||||
|
btn.disabled = false;
|
||||||
|
btn.innerHTML = originalText;
|
||||||
|
lucide.createIcons();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
async function saveRobotConfig() {
|
async function saveRobotConfig() {
|
||||||
const btn = document.querySelector('button[onclick="saveRobotConfig()"]');
|
const btn = document.querySelector('button[onclick="saveRobotConfig()"]');
|
||||||
const originalHtml = btn.innerHTML;
|
const originalHtml = btn.innerHTML;
|
||||||
|
|||||||
Reference in New Issue
Block a user