debug: agregar try/catch y console.log en lab_usuarios.php para diagnosticar render
This commit is contained in:
+20
-2
@@ -269,7 +269,9 @@ let enfermeras = [];
|
|||||||
const roles = {
|
const roles = {
|
||||||
|
|
||||||
async cargar() {
|
async cargar() {
|
||||||
const res = await fetch('api/lab/get_roles.php').then(r => r.json());
|
const r = await fetch('api/lab/get_roles.php');
|
||||||
|
const res = await r.json();
|
||||||
|
console.log('[roles] API respuesta:', res);
|
||||||
allRoles = res.roles ?? [];
|
allRoles = res.roles ?? [];
|
||||||
this.render();
|
this.render();
|
||||||
// Refrescar selector de rol en modal de usuario
|
// Refrescar selector de rol en modal de usuario
|
||||||
@@ -397,13 +399,17 @@ const roles = {
|
|||||||
const usuarios = {
|
const usuarios = {
|
||||||
|
|
||||||
async cargar() {
|
async cargar() {
|
||||||
const res = await fetch('api/lab/get_lab_users.php').then(r => r.json());
|
const r = await fetch('api/lab/get_lab_users.php');
|
||||||
|
const res = await r.json();
|
||||||
|
console.log('[usuarios] API respuesta:', res);
|
||||||
allUsers = res.users ?? [];
|
allUsers = res.users ?? [];
|
||||||
|
console.log('[usuarios] Total a renderizar:', allUsers.length);
|
||||||
this.render();
|
this.render();
|
||||||
},
|
},
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
const tbody = document.getElementById('usuariosTbody');
|
const tbody = document.getElementById('usuariosTbody');
|
||||||
|
console.log('[usuarios.render] tbody:', tbody, '— allUsers:', allUsers.length);
|
||||||
if (!allUsers.length) {
|
if (!allUsers.length) {
|
||||||
tbody.innerHTML = '<tr><td colspan="7" class="text-center py-4 text-muted">No hay usuarios.</td></tr>';
|
tbody.innerHTML = '<tr><td colspan="7" class="text-center py-4 text-muted">No hay usuarios.</td></tr>';
|
||||||
return;
|
return;
|
||||||
@@ -546,8 +552,20 @@ document.getElementById('r_slug').addEventListener('input', function() {
|
|||||||
|
|
||||||
// ── Inicialización ────────────────────────────────────────────────────────────
|
// ── Inicialización ────────────────────────────────────────────────────────────
|
||||||
(async () => {
|
(async () => {
|
||||||
|
try {
|
||||||
await roles.cargar();
|
await roles.cargar();
|
||||||
|
} catch (err) {
|
||||||
|
console.error('[roles.cargar] Error:', err);
|
||||||
|
document.getElementById('rolesGrid').innerHTML =
|
||||||
|
`<div class="col-12 alert alert-danger">Error cargando roles: ${esc(String(err))}</div>`;
|
||||||
|
}
|
||||||
|
try {
|
||||||
await usuarios.cargar();
|
await usuarios.cargar();
|
||||||
|
} catch (err) {
|
||||||
|
console.error('[usuarios.cargar] Error:', err);
|
||||||
|
document.getElementById('usuariosTbody').innerHTML =
|
||||||
|
`<tr><td colspan="7" class="text-danger text-center py-3">Error cargando usuarios: ${esc(String(err))}</td></tr>`;
|
||||||
|
}
|
||||||
})();
|
})();
|
||||||
</script>
|
</script>
|
||||||
</body>
|
</body>
|
||||||
|
|||||||
Reference in New Issue
Block a user