</section>
<!-- Tabella -->
- <table id="dataTable" class="table table-bordered table-hover align-middle">
+ <table id="dataTable" class="table table-bordered table-hover align-middle d-none">
<thead class="table-light">
<tr>
<th data-type="string" data-sortable="true">Alias <span class="sort-arrow" aria-hidden="true"></span></th>
<tbody></tbody>
</table>
+ <!-- Loader -->
+ <div id="loader" class="text-center my-3" style="display: none;">
+ <div class="spinner-border text-primary" role="status">
+ <span class="visually-hidden">Loading...</span>
+ </div>
+ </div>
+ <div id="devices-container"></div>
+
+ <!-- AddAlias -->
<div class="modal fade" id="addAliasModal" tabindex="-1" aria-labelledby="addAliasTitle" aria-hidden="true">
<div class="modal-dialog modal-dialog-centered"><!-- modal-sm|md|lg se vuoi cambiare -->
<div class="modal-content addhost-modal">
</section>
<!-- Tabella -->
- <table id="dataTable" class="table table-bordered table-hover align-middle">
+ <table id="dataTable" class="table table-bordered table-hover align-middle d-none">
<thead class="table-light">
<tr>
<th data-type="string" data-sortable="true">Hostname <span class="sort-arrow" aria-hidden="true"></span></th>
<tbody></tbody>
</table>
+ <!-- Loader -->
+ <div id="loader" class="text-center my-3" style="display: none;">
+ <div class="spinner-border text-primary" role="status">
+ <span class="visually-hidden">Loading...</span>
+ </div>
+ </div>
+ <div id="devices-container"></div>
+
+ <!-- AddHost -->
<div class="modal fade" id="addHostModal" tabindex="-1" aria-labelledby="addHostTitle" aria-hidden="true">
<div class="modal-dialog modal-dialog-centered"><!-- modal-sm|md|lg se vuoi cambiare -->
<div class="modal-content addhost-modal">
// -----------------------------
async function loadAliases() {
let aliases = [];
+ const loader = document.getElementById("loader");
+ const container = document.getElementById("devices-container");
+ const dataTable = document.getElementById("dataTable");
+
+ // hide table during loading to avoid flickering and show loader
+ dataTable.classList.add("d-none");
+
try {
+ // Show loader
+ loader.style.display = "block";
+
// Fetch data
const res = await fetch(`/api/aliases`, {
headers: { Accept: 'application/json' },
console.error(err?.message || "Error loading aliases");
showToast(err?.message || "Error loading aliase", false);
aliases = [];
+ // hide loader and show table
+ loader.style.display = "none";
+ dataTable.classList.remove("d-none");
}
// DOM Reference
sortTable(lastSort.colIndex, sortState);
}
}
+
+ // hide loader and show table
+ loader.style.display = "none";
+ dataTable.classList.remove("d-none");
}
// -----------------------------
// -----------------------------
async function loadHosts() {
let hosts = [];
+ const loader = document.getElementById("loader");
+ const container = document.getElementById("devices-container");
+ const dataTable = document.getElementById("dataTable");
+
+ // hide table during loading to avoid flickering and show loader
+ dataTable.classList.add("d-none");
+
try {
+ // Show loader
+ loader.style.display = "block";
+
// Fetch data
const res = await fetch(`/api/hosts`, {
headers: { Accept: 'application/json' },
console.error(err?.message || "Error loading hosts");
showToast(err?.message || "Error loading hosts", false);
hosts = [];
+ // hide loader and show table
+ loader.style.display = "none";
+ dataTable.classList.remove("d-none");
}
// DOM Reference
if (typeof lastSort === "object" && lastSort && Array.isArray(sortDirection)) {
if (Number.isInteger(lastSort.colIndex)) {
sortDirection[lastSort.colIndex] = !lastSort.ascending;
- sortTable(lastSort.colIndex);
+ sortTable(lastSort.colIndex, sortState);
}
}
+
+ // hide loader and show table
+ loader.style.display = "none";
+ dataTable.classList.remove("d-none");
}
// -----------------------------