fix: editar instancia Coolify trae URL fresca del server y valida base_url no vacio

This commit is contained in:
Lizandro GD
2026-07-22 13:27:02 +00:00
parent a1d4c9da23
commit 772a4a5656
3 changed files with 40 additions and 5 deletions
+19 -5
View File
@@ -1003,13 +1003,27 @@ document.addEventListener('alpine:init', () => {
}
},
openInstModal(cfg = null) {
async openInstModal(cfg = null) {
this.instMsg = '';
this.instEditId = cfg ? (cfg.ID || cfg.id) : null;
this.instForm = cfg
? { nombre: cfg.Nombre || cfg.nombre || '', base_url: cfg.BaseURL || cfg.base_url || '', api_token: '', activo: cfg.Activo ?? cfg.activo ?? true }
: { nombre: '', base_url: '', api_token: '', activo: true };
if (!cfg) {
this.instEditId = null;
this.instForm = { nombre: '', base_url: '', api_token: '', activo: true };
this.instModal = true;
return;
}
const id = cfg.ID || cfg.id;
this.instEditId = id;
// Valores locales como fallback mientras carga
this.instForm = { nombre: cfg.Nombre || cfg.nombre || '', base_url: cfg.BaseURL || cfg.base_url || '', api_token: '', activo: cfg.Activo ?? cfg.activo ?? true };
this.instModal = true;
// Refresco desde el server para garantizar datos actualizados
try {
const r = await fetch(`/app/coolify/configs/${id}`);
if (r.ok) {
const j = await r.json();
this.instForm = { nombre: j.nombre || '', base_url: j.base_url || '', api_token: '', activo: j.activo ?? true };
}
} catch(_) {}
},
async saveInst() {