fix: editar instancia Coolify trae URL fresca del server y valida base_url no vacio
This commit is contained in:
@@ -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() {
|
||||
|
||||
Reference in New Issue
Block a user