Fix admin refresh button layout and add status feedback
This commit is contained in:
@@ -37,8 +37,9 @@
|
|||||||
<label>
|
<label>
|
||||||
Tenant ID:
|
Tenant ID:
|
||||||
<input id="tenantId" value="default" />
|
<input id="tenantId" value="default" />
|
||||||
<button id="refresh" style="margin-left: 0.5rem;">Actualizar módulos</button>
|
|
||||||
</label>
|
</label>
|
||||||
|
<button id="refresh" style="margin-left: 0.5rem;">Actualizar módulos</button>
|
||||||
|
<span id="status" style="margin-left: 1rem; color: #555;"></span>
|
||||||
|
|
||||||
<div id="modules"></div>
|
<div id="modules"></div>
|
||||||
|
|
||||||
@@ -58,12 +59,17 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
async function api(path, options = {}) {
|
async function api(path, options = {}) {
|
||||||
|
const statusEl = document.getElementById('status');
|
||||||
|
statusEl.textContent = 'Consultando ' + path + '...';
|
||||||
const res = await fetch(withTenant(`${apiRoot}${path}`), options);
|
const res = await fetch(withTenant(`${apiRoot}${path}`), options);
|
||||||
const data = await res.json().catch(() => null);
|
const data = await res.json().catch(() => null);
|
||||||
if (!res.ok) {
|
if (!res.ok) {
|
||||||
const err = data?.message ? data.message : res.statusText;
|
const err = data?.message ? data.message : res.statusText;
|
||||||
|
statusEl.textContent = `Error ${res.status}`;
|
||||||
throw new Error(err || `HTTP ${res.status}`);
|
throw new Error(err || `HTTP ${res.status}`);
|
||||||
}
|
}
|
||||||
|
statusEl.textContent = 'OK';
|
||||||
|
setTimeout(() => (statusEl.textContent = ''), 1500);
|
||||||
return data;
|
return data;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user