APmanageur Wi-Fi V1.0

This commit is contained in:
yoannmultigaming committed 2026-11-22 20:55:05 +01:00
1 parent ff54694291
commit 6f353a5ff5
3 files changed
+115 -34

No files matched your search

+17 -3
View File
@@ -9409,7 +9409,7 @@ ${vpnBadgeTopo}
const nameLabel = String(c.name || t('name_unknown', 'Nom non communiqué')).replace(/[&<>"']/g, ch => '&#' + ch.charCodeAt(0) + ';');
const blockBtnLabel = c.blocked ? t('btn_unblock', 'Débloquer') : t('btn_block', 'Bloquer');
const quotaBtnLabel = '⚖️ ' + t('btn_quota', 'Quota');
return `<tr><td><div class="client"><div class="avatar">${String(c.name || '?')[0].toUpperCase()}</div><strong>${nameLabel}</strong></div></td><td>${ipLabel}</td><td>${c.mac || '—'}</td><td>${vpnHtml}</td><td>${signalQuality(c.signal_dbm, c)}</td><td>${speedHtml}</td><td><div style="display:inline-flex;gap:4px;align-items:center"><button class="secondary" type="button" style="padding:4px 8px;font-size:11px" onclick="openDeviceLimitsModal('${c.mac}')" title="${t('modal_limits_title', 'Gérer le quota et la limitation de débit')}">${quotaBtnLabel}</button><button class="secondary" type="button" onclick="toggleBlock('${c.mac}',${!c.blocked})">${blockBtnLabel}</button></div></td></tr>`;
return `<tr><td><div class="client"><div class="avatar">${String(c.name || '?')[0].toUpperCase()}</div><div style="display:flex;align-items:center;gap:6px"><strong>${nameLabel}</strong><button class="secondary" type="button" style="padding:2px 5px;font-size:11px;line-height:1;border-radius:4px" onclick="renameDevice('${c.mac}')" title="${t('rename_device_attr', 'Renommer cet appareil')}">✏️</button></div></div></td><td>${ipLabel}</td><td>${c.mac || '—'}</td><td>${vpnHtml}</td><td>${signalQuality(c.signal_dbm, c)}</td><td>${speedHtml}</td><td><div style="display:inline-flex;gap:4px;align-items:center"><button class="secondary" type="button" style="padding:4px 8px;font-size:11px" onclick="openDeviceLimitsModal('${c.mac}')" title="${t('modal_limits_title', 'Gérer le quota et la limitation de débit')}">${quotaBtnLabel}</button><button class="secondary" type="button" onclick="toggleBlock('${c.mac}',${!c.blocked})">${blockBtnLabel}</button></div></td></tr>`;
}).join('') : `<tr><td colspan="7" class="empty">${t('no_clients', 'Aucun client connecté')}</td></tr>`;
renderPagination('clientsPagination', clientsPage, clients.length, 'changeClientsPage', 10);
@@ -9775,7 +9775,10 @@ ${vpnBadgeTopo}
};
async function renameDevice(mac) {
const dev = devicesDataCache.find(d => d.mac.toUpperCase() === mac.toUpperCase());
if (!mac) return;
const mUpper = mac.toUpperCase();
const dev = ((typeof devicesDataCache !== 'undefined' && Array.isArray(devicesDataCache)) ? devicesDataCache.find(d => d.mac && d.mac.toUpperCase() === mUpper) : null) ||
((typeof clients !== 'undefined' && Array.isArray(clients)) ? clients.find(c => c.mac && c.mac.toUpperCase() === mUpper) : null);
const currentName = dev ? dev.name : '';
const newName = prompt(t('prompt_device_name', "Entrez un nom personnalisé pour cet appareil :"), currentName || "");
if (newName === null) return;
@@ -9785,10 +9788,21 @@ ${vpnBadgeTopo}
const res = await apiFetch('/api/devices/rename', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({ mac, name: trimmed })
body: JSON.stringify({ mac: mUpper, name: trimmed })
});
const d = await res.json();
if (!res.ok) throw new Error(d.error || 'Erreur lors du renommage');
// Mise à jour immédiate des caches pour un retour visuel instantané
if (typeof devicesDataCache !== 'undefined' && Array.isArray(devicesDataCache)) {
const dItem = devicesDataCache.find(x => x.mac && x.mac.toUpperCase() === mUpper);
if (dItem) dItem.name = trimmed;
}
if (typeof clients !== 'undefined' && Array.isArray(clients)) {
const cItem = clients.find(x => x.mac && x.mac.toUpperCase() === mUpper);
if (cItem) cItem.name = trimmed;
}
renderDevicesTable();
render();
await loadDevices();
await load();
} catch (e) {