APmanageur Wi-Fi V1.0
This commit is contained in:
1 parent
95641a8ac8
commit
1f8f295950
9 files changed
+2445
-292
No files matched your search
+403
-292
@@ -512,6 +512,35 @@
|
||||
color: #e6f6ff !important;
|
||||
}
|
||||
|
||||
/* Boutons de sélection de jeu Easter Egg */
|
||||
.game-switch-btn.active {
|
||||
background: var(--blue) !important;
|
||||
color: var(--blue-text, #071326) !important;
|
||||
border-color: var(--blue) !important;
|
||||
font-weight: 700 !important;
|
||||
}
|
||||
html[data-theme="light"] .game-switch-btn.active,
|
||||
html[data-theme="winxp"] .game-switch-btn.active,
|
||||
html[data-theme="macos"][data-macos-mode="light"] .game-switch-btn.active,
|
||||
html[data-theme="macos"]:not([data-macos-mode="dark"]) .game-switch-btn.active {
|
||||
background: var(--blue) !important;
|
||||
color: #ffffff !important;
|
||||
}
|
||||
|
||||
.game-switch-btn.active {
|
||||
background: var(--blue) !important;
|
||||
color: var(--blue-text, #071326) !important;
|
||||
border-color: var(--blue) !important;
|
||||
font-weight: 700 !important;
|
||||
}
|
||||
html[data-theme="light"] .game-switch-btn.active,
|
||||
html[data-theme="winxp"] .game-switch-btn.active,
|
||||
html[data-theme="macos"][data-macos-mode="light"] .game-switch-btn.active,
|
||||
html[data-theme="macos"]:not([data-macos-mode="dark"]) .game-switch-btn.active {
|
||||
background: var(--blue) !important;
|
||||
color: #ffffff !important;
|
||||
}
|
||||
|
||||
#btnAuthPasskey {
|
||||
border: 1px solid rgba(56, 189, 248, 0.4);
|
||||
background: rgba(56, 189, 248, 0.08);
|
||||
@@ -6157,6 +6186,32 @@
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- 10. Modal Easter Egg Arcade Games (Tetris, Dino, Zipline) -->
|
||||
<div id="modalEasterEggGames" class="modal-overlay" style="z-index:99999">
|
||||
<div class="modal-card" style="max-width:760px;width:96%;max-height:92vh;display:flex;flex-direction:column;padding:0;overflow:hidden;border:1px solid var(--blue);box-shadow:0 0 35px rgba(92,167,255,0.25)">
|
||||
<div class="modal-header" style="padding:12px 18px;background:var(--panel2);border-bottom:1px solid var(--line);display:flex;align-items:center;justify-content:space-between;flex-wrap:wrap;gap:10px">
|
||||
<div style="display:flex;align-items:center;gap:10px">
|
||||
<span style="font-size:22px">🕹️</span>
|
||||
<div>
|
||||
<h2 style="margin:0;font-size:16px;display:flex;align-items:center;gap:8px">
|
||||
<span data-i18n="arcade_title">Arcade AP Manageur</span>
|
||||
<span class="pill pill-blue pill-no-dot" style="font-size:10px;padding:2px 7px">Easter Egg</span>
|
||||
</h2>
|
||||
</div>
|
||||
</div>
|
||||
<div style="display:flex;align-items:center;gap:6px;flex-wrap:wrap">
|
||||
<button type="button" id="btnEggGame_tetris" class="secondary game-switch-btn active" onclick="switchEasterEggGame('tetris')" style="padding:5px 12px;font-size:12px;border-radius:6px;display:inline-flex;align-items:center;gap:4px">🧱 <span>Tetris</span></button>
|
||||
<button type="button" id="btnEggGame_dino" class="secondary game-switch-btn" onclick="switchEasterEggGame('dino')" style="padding:5px 12px;font-size:12px;border-radius:6px;display:inline-flex;align-items:center;gap:4px">🦖 <span>Dino T-Rex</span></button>
|
||||
<button type="button" id="btnEggGame_zipline" class="secondary game-switch-btn" onclick="switchEasterEggGame('zipline')" style="padding:5px 12px;font-size:12px;border-radius:6px;display:inline-flex;align-items:center;gap:4px">⚡ <span>Zip (LinkedIn)</span></button>
|
||||
<button type="button" class="secondary" style="padding:4px 10px;font-size:16px;margin-left:4px" onclick="closeEasterEggModal()" title="Fermer (Échap)">✕</button>
|
||||
</div>
|
||||
</div>
|
||||
<div class="modal-body" style="padding:0;flex:1;background:#071326;display:flex;justify-content:center;align-items:center;min-height:560px">
|
||||
<iframe id="easterEggGameIframe" src="" style="width:100%;height:580px;border:0;display:block" title="Easter Egg Game" allow="autoplay"></iframe>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</main>
|
||||
|
||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/qrcodejs/1.0.0/qrcode.min.js" defer></script>
|
||||
@@ -8807,6 +8862,93 @@ ${vpnBadgeTopo}
|
||||
}
|
||||
}
|
||||
|
||||
/* --- Easter Egg Arcade Games (jeu:Tetris, jeu:dino, jeu:zipline) --- */
|
||||
let currentEasterEggGame = 'tetris';
|
||||
|
||||
window.openEasterEggModal = function (gameName = 'tetris') {
|
||||
const modal = $('modalEasterEggGames');
|
||||
if (!modal) return;
|
||||
modal.classList.add('active');
|
||||
modal.style.display = 'flex';
|
||||
switchEasterEggGame(gameName);
|
||||
};
|
||||
|
||||
window.closeEasterEggModal = function () {
|
||||
const modal = $('modalEasterEggGames');
|
||||
if (modal) {
|
||||
modal.classList.remove('active');
|
||||
modal.style.display = 'none';
|
||||
}
|
||||
const iframe = $('easterEggGameIframe');
|
||||
if (iframe) iframe.src = '';
|
||||
};
|
||||
|
||||
window.switchEasterEggGame = function (gameName) {
|
||||
currentEasterEggGame = gameName;
|
||||
const validGames = ['tetris', 'dino', 'zipline'];
|
||||
if (!validGames.includes(gameName)) gameName = 'tetris';
|
||||
|
||||
document.querySelectorAll('.game-switch-btn').forEach(btn => {
|
||||
const isActive = (btn.id === 'btnEggGame_' + gameName);
|
||||
btn.classList.toggle('active', isActive);
|
||||
});
|
||||
|
||||
const iframe = $('easterEggGameIframe');
|
||||
if (iframe) {
|
||||
iframe.src = '/jeux/' + gameName + '.html';
|
||||
setTimeout(() => {
|
||||
try { iframe.focus(); if (iframe.contentWindow) iframe.contentWindow.focus(); } catch (e) { }
|
||||
}, 150);
|
||||
}
|
||||
};
|
||||
|
||||
function parseEasterEggGameName(rawVal) {
|
||||
if (!rawVal || typeof rawVal !== 'string') return null;
|
||||
const clean = rawVal.trim();
|
||||
const m = clean.match(/^jeu\s*:\s*(.*)$/i) || (clean.toLowerCase() === 'jeu' ? ['', 'tetris'] : null);
|
||||
if (!m) return null;
|
||||
let g = (m[1] || 'tetris').trim().toLowerCase();
|
||||
if (g === 'dinausore' || g === 'dinosaure' || g === 'trex' || g === 't-rex' || g === 'chrome') return 'dino';
|
||||
if (g === 'zip' || g === 'zipline' || g === 'linkedin') return 'zipline';
|
||||
if (g === 'tetris' || g === '') return 'tetris';
|
||||
return g;
|
||||
}
|
||||
|
||||
function attachEasterEggTrigger(inputEl) {
|
||||
if (!inputEl) return;
|
||||
inputEl.addEventListener('keydown', (e) => {
|
||||
if (e.key === 'Enter') {
|
||||
const game = parseEasterEggGameName(inputEl.value);
|
||||
if (game) {
|
||||
e.preventDefault();
|
||||
e.stopPropagation();
|
||||
openEasterEggModal(game);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
// Attacher le déclencheur aux barres de recherche de l'onglet Avancé
|
||||
attachEasterEggTrigger($('vpnClientsSearchInput'));
|
||||
attachEasterEggTrigger($('packetFilterInput'));
|
||||
// Et pour une meilleure accessibilité, à la recherche des appareils également
|
||||
attachEasterEggTrigger($('devicesSearchInput'));
|
||||
|
||||
// Fermeture par la touche Échap et clic extérieur
|
||||
window.addEventListener('keydown', (e) => {
|
||||
if (e.key === 'Escape') {
|
||||
const m = $('modalEasterEggGames');
|
||||
if (m && m.classList.contains('active')) {
|
||||
closeEasterEggModal();
|
||||
}
|
||||
}
|
||||
});
|
||||
if ($('modalEasterEggGames')) {
|
||||
$('modalEasterEggGames').onclick = (e) => {
|
||||
if (e.target === $('modalEasterEggGames')) closeEasterEggModal();
|
||||
};
|
||||
}
|
||||
|
||||
async function toggleBlockDevice(mac, blocked) {
|
||||
try {
|
||||
await toggleBlock(mac, blocked);
|
||||
@@ -8817,6 +8959,93 @@ ${vpnBadgeTopo}
|
||||
}
|
||||
}
|
||||
|
||||
/* --- Easter Egg Arcade Games (jeu:Tetris, jeu:dino, jeu:zipline) --- */
|
||||
let currentEasterEggGame = 'tetris';
|
||||
|
||||
window.openEasterEggModal = function (gameName = 'tetris') {
|
||||
const modal = $('modalEasterEggGames');
|
||||
if (!modal) return;
|
||||
modal.classList.add('active');
|
||||
modal.style.display = 'flex';
|
||||
switchEasterEggGame(gameName);
|
||||
};
|
||||
|
||||
window.closeEasterEggModal = function () {
|
||||
const modal = $('modalEasterEggGames');
|
||||
if (modal) {
|
||||
modal.classList.remove('active');
|
||||
modal.style.display = 'none';
|
||||
}
|
||||
const iframe = $('easterEggGameIframe');
|
||||
if (iframe) iframe.src = '';
|
||||
};
|
||||
|
||||
window.switchEasterEggGame = function (gameName) {
|
||||
currentEasterEggGame = gameName;
|
||||
const validGames = ['tetris', 'dino', 'zipline'];
|
||||
if (!validGames.includes(gameName)) gameName = 'tetris';
|
||||
|
||||
document.querySelectorAll('.game-switch-btn').forEach(btn => {
|
||||
const isActive = (btn.id === 'btnEggGame_' + gameName);
|
||||
btn.classList.toggle('active', isActive);
|
||||
});
|
||||
|
||||
const iframe = $('easterEggGameIframe');
|
||||
if (iframe) {
|
||||
iframe.src = '/jeux/' + gameName + '.html';
|
||||
setTimeout(() => {
|
||||
try { iframe.focus(); if (iframe.contentWindow) iframe.contentWindow.focus(); } catch (e) { }
|
||||
}, 150);
|
||||
}
|
||||
};
|
||||
|
||||
function parseEasterEggGameName(rawVal) {
|
||||
if (!rawVal || typeof rawVal !== 'string') return null;
|
||||
const clean = rawVal.trim();
|
||||
const m = clean.match(/^jeu\s*:\s*(.*)$/i) || (clean.toLowerCase() === 'jeu' ? ['', 'tetris'] : null);
|
||||
if (!m) return null;
|
||||
let g = (m[1] || 'tetris').trim().toLowerCase();
|
||||
if (g === 'dinausore' || g === 'dinosaure' || g === 'trex' || g === 't-rex' || g === 'chrome') return 'dino';
|
||||
if (g === 'zip' || g === 'zipline' || g === 'linkedin') return 'zipline';
|
||||
if (g === 'tetris' || g === '') return 'tetris';
|
||||
return g;
|
||||
}
|
||||
|
||||
function attachEasterEggTrigger(inputEl) {
|
||||
if (!inputEl) return;
|
||||
inputEl.addEventListener('keydown', (e) => {
|
||||
if (e.key === 'Enter') {
|
||||
const game = parseEasterEggGameName(inputEl.value);
|
||||
if (game) {
|
||||
e.preventDefault();
|
||||
e.stopPropagation();
|
||||
openEasterEggModal(game);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
// Attacher le déclencheur aux barres de recherche de l'onglet Avancé
|
||||
attachEasterEggTrigger($('vpnClientsSearchInput'));
|
||||
attachEasterEggTrigger($('packetFilterInput'));
|
||||
// Et pour une meilleure accessibilité, à la recherche des appareils également
|
||||
attachEasterEggTrigger($('devicesSearchInput'));
|
||||
|
||||
// Fermeture par la touche Échap et clic extérieur
|
||||
window.addEventListener('keydown', (e) => {
|
||||
if (e.key === 'Escape') {
|
||||
const m = $('modalEasterEggGames');
|
||||
if (m && m.classList.contains('active')) {
|
||||
closeEasterEggModal();
|
||||
}
|
||||
}
|
||||
});
|
||||
if ($('modalEasterEggGames')) {
|
||||
$('modalEasterEggGames').onclick = (e) => {
|
||||
if (e.target === $('modalEasterEggGames')) closeEasterEggModal();
|
||||
};
|
||||
}
|
||||
|
||||
async function deleteDeviceHistory(mac) {
|
||||
const dev = devicesDataCache.find(d => d.mac.toUpperCase() === mac.toUpperCase());
|
||||
const name = dev ? dev.name : mac;
|
||||
@@ -8835,6 +9064,93 @@ ${vpnBadgeTopo}
|
||||
}
|
||||
}
|
||||
|
||||
/* --- Easter Egg Arcade Games (jeu:Tetris, jeu:dino, jeu:zipline) --- */
|
||||
let currentEasterEggGame = 'tetris';
|
||||
|
||||
window.openEasterEggModal = function (gameName = 'tetris') {
|
||||
const modal = $('modalEasterEggGames');
|
||||
if (!modal) return;
|
||||
modal.classList.add('active');
|
||||
modal.style.display = 'flex';
|
||||
switchEasterEggGame(gameName);
|
||||
};
|
||||
|
||||
window.closeEasterEggModal = function () {
|
||||
const modal = $('modalEasterEggGames');
|
||||
if (modal) {
|
||||
modal.classList.remove('active');
|
||||
modal.style.display = 'none';
|
||||
}
|
||||
const iframe = $('easterEggGameIframe');
|
||||
if (iframe) iframe.src = '';
|
||||
};
|
||||
|
||||
window.switchEasterEggGame = function (gameName) {
|
||||
currentEasterEggGame = gameName;
|
||||
const validGames = ['tetris', 'dino', 'zipline'];
|
||||
if (!validGames.includes(gameName)) gameName = 'tetris';
|
||||
|
||||
document.querySelectorAll('.game-switch-btn').forEach(btn => {
|
||||
const isActive = (btn.id === 'btnEggGame_' + gameName);
|
||||
btn.classList.toggle('active', isActive);
|
||||
});
|
||||
|
||||
const iframe = $('easterEggGameIframe');
|
||||
if (iframe) {
|
||||
iframe.src = '/jeux/' + gameName + '.html';
|
||||
setTimeout(() => {
|
||||
try { iframe.focus(); if (iframe.contentWindow) iframe.contentWindow.focus(); } catch (e) { }
|
||||
}, 150);
|
||||
}
|
||||
};
|
||||
|
||||
function parseEasterEggGameName(rawVal) {
|
||||
if (!rawVal || typeof rawVal !== 'string') return null;
|
||||
const clean = rawVal.trim();
|
||||
const m = clean.match(/^jeu\s*:\s*(.*)$/i) || (clean.toLowerCase() === 'jeu' ? ['', 'tetris'] : null);
|
||||
if (!m) return null;
|
||||
let g = (m[1] || 'tetris').trim().toLowerCase();
|
||||
if (g === 'dinausore' || g === 'dinosaure' || g === 'trex' || g === 't-rex' || g === 'chrome') return 'dino';
|
||||
if (g === 'zip' || g === 'zipline' || g === 'linkedin') return 'zipline';
|
||||
if (g === 'tetris' || g === '') return 'tetris';
|
||||
return g;
|
||||
}
|
||||
|
||||
function attachEasterEggTrigger(inputEl) {
|
||||
if (!inputEl) return;
|
||||
inputEl.addEventListener('keydown', (e) => {
|
||||
if (e.key === 'Enter') {
|
||||
const game = parseEasterEggGameName(inputEl.value);
|
||||
if (game) {
|
||||
e.preventDefault();
|
||||
e.stopPropagation();
|
||||
openEasterEggModal(game);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
// Attacher le déclencheur aux barres de recherche de l'onglet Avancé
|
||||
attachEasterEggTrigger($('vpnClientsSearchInput'));
|
||||
attachEasterEggTrigger($('packetFilterInput'));
|
||||
// Et pour une meilleure accessibilité, à la recherche des appareils également
|
||||
attachEasterEggTrigger($('devicesSearchInput'));
|
||||
|
||||
// Fermeture par la touche Échap et clic extérieur
|
||||
window.addEventListener('keydown', (e) => {
|
||||
if (e.key === 'Escape') {
|
||||
const m = $('modalEasterEggGames');
|
||||
if (m && m.classList.contains('active')) {
|
||||
closeEasterEggModal();
|
||||
}
|
||||
}
|
||||
});
|
||||
if ($('modalEasterEggGames')) {
|
||||
$('modalEasterEggGames').onclick = (e) => {
|
||||
if (e.target === $('modalEasterEggGames')) closeEasterEggModal();
|
||||
};
|
||||
}
|
||||
|
||||
/* ============================================================
|
||||
Gestion des Quotas & Limitation de Débit par Appareil
|
||||
============================================================ */
|
||||
@@ -8852,295 +9168,6 @@ ${vpnBadgeTopo}
|
||||
if ($('limitsModalMac')) $('limitsModalMac').value = cleanMac;
|
||||
if ($('limitsDevName')) $('limitsDevName').textContent = dev.name || 'Client sans nom';
|
||||
if ($('limitsDevMac')) $('limitsDevMac').textContent = cleanMac;
|
||||
if ($('limitsDevIp')) $('limitsDevIp').textContent = dev.ip && dev.ip !== 'Non attribuée' ? dev.ip : 'Non attribuée';
|
||||
if ($('limitsDevAvatar')) $('limitsDevAvatar').innerHTML = getDeviceTypeIcon(dev.device_type);
|
||||
if ($('deviceLimitsMsg')) $('deviceLimitsMsg').style.display = 'none';
|
||||
|
||||
function applyLimitsToForm(lim) {
|
||||
lim = lim || {};
|
||||
if ($('chkLimitsQuotaEnabled')) $('chkLimitsQuotaEnabled').checked = !!lim.quota_enabled;
|
||||
|
||||
// Quota bytes -> valeur + unité
|
||||
const qBytes = lim.quota_bytes || 0;
|
||||
if (qBytes > 0) {
|
||||
if (qBytes % 1073741824 === 0 || qBytes >= 1073741824) {
|
||||
if ($('inputQuotaValue')) $('inputQuotaValue').value = (qBytes / 1073741824);
|
||||
if ($('selectQuotaUnit')) $('selectQuotaUnit').value = 'GB';
|
||||
} else {
|
||||
if ($('inputQuotaValue')) $('inputQuotaValue').value = Math.round(qBytes / 1048576);
|
||||
if ($('selectQuotaUnit')) $('selectQuotaUnit').value = 'MB';
|
||||
}
|
||||
} else {
|
||||
if ($('inputQuotaValue')) $('inputQuotaValue').value = 10;
|
||||
if ($('selectQuotaUnit')) $('selectQuotaUnit').value = 'GB';
|
||||
}
|
||||
if ($('selectQuotaPeriod')) $('selectQuotaPeriod').value = lim.quota_period || 'total';
|
||||
|
||||
// Bande passante
|
||||
if ($('chkLimitsBwEnabled')) $('chkLimitsBwEnabled').checked = !!lim.bandwidth_enabled;
|
||||
const downKbps = lim.rate_down_kbps || 0;
|
||||
if (downKbps >= 1000 && downKbps % 1000 === 0) {
|
||||
if ($('inputRateDown')) $('inputRateDown').value = downKbps / 1000;
|
||||
if ($('selectRateDownUnit')) $('selectRateDownUnit').value = 'Mbps';
|
||||
} else {
|
||||
if ($('inputRateDown')) $('inputRateDown').value = downKbps || 10;
|
||||
if ($('selectRateDownUnit')) $('selectRateDownUnit').value = downKbps ? 'Kbps' : 'Mbps';
|
||||
}
|
||||
|
||||
const upKbps = lim.rate_up_kbps || 0;
|
||||
if (upKbps >= 1000 && upKbps % 1000 === 0) {
|
||||
if ($('inputRateUp')) $('inputRateUp').value = upKbps / 1000;
|
||||
if ($('selectRateUpUnit')) $('selectRateUpUnit').value = 'Mbps';
|
||||
} else {
|
||||
if ($('inputRateUp')) $('inputRateUp').value = upKbps || 5;
|
||||
if ($('selectRateUpUnit')) $('selectRateUpUnit').value = upKbps ? 'Kbps' : 'Mbps';
|
||||
}
|
||||
|
||||
toggleQuotaInputs();
|
||||
toggleBwInputs();
|
||||
updateQuotaPreview();
|
||||
}
|
||||
|
||||
// Appliquer immédiatement les données en cache pour ouverture instantanée
|
||||
applyLimitsToForm(currentLimitsDev.limits || {});
|
||||
|
||||
const modal = $('modalDeviceLimits');
|
||||
if (modal) modal.classList.add('active');
|
||||
|
||||
// Rafraîchir en arrière-plan depuis l'API
|
||||
try {
|
||||
const res = await apiFetch(`/api/devices/limits?mac=${encodeURIComponent(cleanMac)}`, { timeout: 15000 });
|
||||
if (res.ok) {
|
||||
const data = await res.json();
|
||||
if (data && data.limits) {
|
||||
currentLimitsDev.limits = data.limits;
|
||||
applyLimitsToForm(currentLimitsDev.limits);
|
||||
}
|
||||
}
|
||||
} catch (e) {
|
||||
console.warn("Impossible de rafraîchir les limites de l'appareil :", e);
|
||||
}
|
||||
}
|
||||
|
||||
function closeDeviceLimitsModal() {
|
||||
const modal = $('modalDeviceLimits');
|
||||
if (modal) modal.classList.remove('active');
|
||||
currentLimitsDev = null;
|
||||
}
|
||||
|
||||
function toggleQuotaInputs() {
|
||||
const enabled = $('chkLimitsQuotaEnabled') && $('chkLimitsQuotaEnabled').checked;
|
||||
const container = $('quotaInputsContainer');
|
||||
if (container) container.style.display = enabled ? 'flex' : 'none';
|
||||
updateQuotaPreview();
|
||||
}
|
||||
|
||||
function toggleBwInputs() {
|
||||
const enabled = $('chkLimitsBwEnabled') && $('chkLimitsBwEnabled').checked;
|
||||
const container = $('bwInputsContainer');
|
||||
if (container) container.style.display = enabled ? 'flex' : 'none';
|
||||
}
|
||||
|
||||
function setQuotaPreset(val, unit) {
|
||||
if ($('inputQuotaValue')) $('inputQuotaValue').value = val;
|
||||
if ($('selectQuotaUnit')) $('selectQuotaUnit').value = unit;
|
||||
updateQuotaPreview();
|
||||
}
|
||||
|
||||
function setBwPreset(downMbps, upMbps) {
|
||||
if ($('inputRateDown')) $('inputRateDown').value = downMbps;
|
||||
if ($('selectRateDownUnit')) $('selectRateDownUnit').value = 'Mbps';
|
||||
if ($('inputRateUp')) $('inputRateUp').value = upMbps;
|
||||
if ($('selectRateUpUnit')) $('selectRateUpUnit').value = 'Mbps';
|
||||
}
|
||||
|
||||
async function onQuotaPeriodChanged() {
|
||||
if (!currentLimitsDev) return;
|
||||
try {
|
||||
const res = await apiFetch(`/api/devices/limits?mac=${encodeURIComponent(currentLimitsDev.mac)}`);
|
||||
if (res.ok) {
|
||||
const data = await res.json();
|
||||
if (data && data.limits) {
|
||||
currentLimitsDev.limits = data.limits;
|
||||
}
|
||||
}
|
||||
} catch (_) { }
|
||||
updateQuotaPreview();
|
||||
}
|
||||
|
||||
function updateQuotaPreview() {
|
||||
if (!currentLimitsDev) return;
|
||||
const lim = currentLimitsDev.limits || {};
|
||||
const usageBytes = lim.usage_bytes || 0;
|
||||
const usageStr = lim.usage_bytes_str || formatBytes(usageBytes);
|
||||
|
||||
let qVal = parseFloat($('inputQuotaValue') ? $('inputQuotaValue').value : 0) || 0;
|
||||
const qUnit = $('selectQuotaUnit') ? $('selectQuotaUnit').value : 'GB';
|
||||
const qBytes = qUnit === 'GB' ? Math.round(qVal * 1073741824) : Math.round(qVal * 1048576);
|
||||
|
||||
const exceeded = qBytes > 0 && usageBytes >= qBytes;
|
||||
const pct = qBytes > 0 ? Math.min(100, Math.round((usageBytes / qBytes) * 100)) : 0;
|
||||
const remaining = Math.max(0, qBytes - usageBytes);
|
||||
|
||||
if ($('quotaExceededBadge')) $('quotaExceededBadge').style.display = exceeded ? 'inline-block' : 'none';
|
||||
|
||||
if ($('quotaUsageLabel')) {
|
||||
$('quotaUsageLabel').textContent = `${usageStr} / ${formatBytes(qBytes)} (${pct}%)`;
|
||||
$('quotaUsageLabel').style.color = exceeded ? 'var(--red)' : (pct >= 85 ? '#f59e0b' : 'var(--text)');
|
||||
}
|
||||
if ($('quotaUsageBar')) {
|
||||
$('quotaUsageBar').style.width = `${pct}%`;
|
||||
$('quotaUsageBar').style.background = exceeded ? 'var(--red)' : (pct >= 85 ? '#f59e0b' : 'var(--blue)');
|
||||
}
|
||||
if ($('quotaRemainingLabel')) {
|
||||
$('quotaRemainingLabel').textContent = exceeded ? t('modal_quota_exhausted', 'Quota épuisé (0 o restant)') : `${t('modal_quota_remaining', 'Reste :')} ${formatBytes(remaining)}`;
|
||||
$('quotaRemainingLabel').style.color = exceeded ? 'var(--red)' : 'var(--muted)';
|
||||
}
|
||||
}
|
||||
|
||||
async function resetDeviceTrafficUsage() {
|
||||
if (!currentLimitsDev) return;
|
||||
const mac = currentLimitsDev.mac;
|
||||
const name = currentLimitsDev.name || mac;
|
||||
if (!confirm(t('confirm_reset_quota', "Voulez-vous remettre à zéro le compteur de données de l'appareil « {name} » ?").replace('{name}', name))) return;
|
||||
|
||||
try {
|
||||
const res = await apiFetch('/api/devices/limits', {
|
||||
method: 'POST',
|
||||
headers: { 'Content-Type': 'application/json' },
|
||||
timeout: 30000,
|
||||
body: JSON.stringify({
|
||||
mac: mac,
|
||||
quota_enabled: $('chkLimitsQuotaEnabled') && $('chkLimitsQuotaEnabled').checked,
|
||||
quota_bytes: getSelectedQuotaBytes(),
|
||||
quota_period: $('selectQuotaPeriod') ? $('selectQuotaPeriod').value : 'total',
|
||||
bandwidth_enabled: $('chkLimitsBwEnabled') && $('chkLimitsBwEnabled').checked,
|
||||
rate_down_kbps: getSelectedRateDownKbps(),
|
||||
rate_up_kbps: getSelectedRateUpKbps(),
|
||||
reset_usage: true
|
||||
})
|
||||
});
|
||||
const d = await res.json();
|
||||
if (!res.ok) throw new Error(d.error || 'Erreur lors de la réinitialisation');
|
||||
|
||||
if (d.limits) currentLimitsDev.limits = d.limits;
|
||||
updateQuotaPreview();
|
||||
const msg = $('deviceLimitsMsg');
|
||||
if (msg) {
|
||||
msg.style.display = 'block';
|
||||
msg.style.background = 'rgba(50,213,131,0.15)';
|
||||
msg.style.color = 'var(--green)';
|
||||
msg.textContent = t('modal_counter_reset_ok', '✓ Compteur de consommation remis à zéro !');
|
||||
setTimeout(() => { if (msg) msg.style.display = 'none'; }, 4000);
|
||||
}
|
||||
try { await loadDevices(); } catch (_) { }
|
||||
try { await load(); } catch (_) { }
|
||||
} catch (e) {
|
||||
alert(tErr(e.message));
|
||||
}
|
||||
}
|
||||
|
||||
function getSelectedQuotaBytes() {
|
||||
const val = parseFloat($('inputQuotaValue') ? $('inputQuotaValue').value : 0) || 0;
|
||||
const unit = $('selectQuotaUnit') ? $('selectQuotaUnit').value : 'GB';
|
||||
return unit === 'GB' ? Math.round(val * 1073741824) : Math.round(val * 1048576);
|
||||
}
|
||||
|
||||
function getSelectedRateDownKbps() {
|
||||
const val = parseFloat($('inputRateDown') ? $('inputRateDown').value : 0) || 0;
|
||||
const unit = $('selectRateDownUnit') ? $('selectRateDownUnit').value : 'Mbps';
|
||||
return unit === 'Mbps' ? Math.round(val * 1000) : Math.round(val);
|
||||
}
|
||||
|
||||
function getSelectedRateUpKbps() {
|
||||
const val = parseFloat($('inputRateUp') ? $('inputRateUp').value : 0) || 0;
|
||||
const unit = $('selectRateUpUnit') ? $('selectRateUpUnit').value : 'Mbps';
|
||||
return unit === 'Mbps' ? Math.round(val * 1000) : Math.round(val);
|
||||
}
|
||||
|
||||
async function submitDeviceLimits() {
|
||||
if (!currentLimitsDev) return;
|
||||
const mac = currentLimitsDev.mac;
|
||||
const btn = $('btnSaveDeviceLimits');
|
||||
const msg = $('deviceLimitsMsg');
|
||||
|
||||
const quotaEnabled = $('chkLimitsQuotaEnabled') && $('chkLimitsQuotaEnabled').checked;
|
||||
const quotaBytes = getSelectedQuotaBytes();
|
||||
const quotaPeriod = $('selectQuotaPeriod') ? $('selectQuotaPeriod').value : 'total';
|
||||
|
||||
const bwEnabled = $('chkLimitsBwEnabled') && $('chkLimitsBwEnabled').checked;
|
||||
const rateDownKbps = getSelectedRateDownKbps();
|
||||
const rateUpKbps = getSelectedRateUpKbps();
|
||||
|
||||
if (btn) { btn.disabled = true; btn.textContent = t('loading', 'Enregistrement…'); }
|
||||
if (msg) {
|
||||
msg.style.display = 'block';
|
||||
msg.style.background = 'rgba(56,189,248,0.12)';
|
||||
msg.style.color = 'var(--blue)';
|
||||
msg.textContent = t('modal_saving', 'Application des quotas et limitations réseau…');
|
||||
}
|
||||
|
||||
try {
|
||||
const res = await apiFetch('/api/devices/limits', {
|
||||
method: 'POST',
|
||||
headers: { 'Content-Type': 'application/json' },
|
||||
timeout: 30000,
|
||||
body: JSON.stringify({
|
||||
mac,
|
||||
quota_enabled: quotaEnabled,
|
||||
quota_bytes: quotaBytes,
|
||||
quota_period: quotaPeriod,
|
||||
bandwidth_enabled: bwEnabled,
|
||||
rate_down_kbps: rateDownKbps,
|
||||
rate_up_kbps: rateUpKbps,
|
||||
quota_action: 'block'
|
||||
})
|
||||
});
|
||||
const d = await res.json();
|
||||
if (!res.ok) throw new Error(d.error || 'Erreur lors de l’enregistrement');
|
||||
|
||||
if (msg) {
|
||||
msg.style.background = 'rgba(50,213,131,0.15)';
|
||||
msg.style.color = 'var(--green)';
|
||||
msg.textContent = t('modal_saved_ok', '✓ Limitations enregistrées et appliquées avec succès !');
|
||||
}
|
||||
|
||||
setTimeout(() => {
|
||||
closeDeviceLimitsModal();
|
||||
}, 900);
|
||||
|
||||
try { await loadDevices(); } catch (_) { }
|
||||
try { await load(); } catch (_) { }
|
||||
} catch (e) {
|
||||
if (msg) {
|
||||
msg.style.background = 'rgba(239,68,68,0.15)';
|
||||
msg.style.color = 'var(--red)';
|
||||
msg.textContent = tErr(e.message);
|
||||
}
|
||||
} finally {
|
||||
if (btn) { btn.disabled = false; btn.innerHTML = '<span>💾</span> ' + t('modal_save_limits', 'Enregistrer les limitations'); }
|
||||
}
|
||||
}
|
||||
|
||||
let selectedDeviceType = 'generic';
|
||||
|
||||
function openDeviceTypeModal(mac) {
|
||||
const dev = devicesDataCache.find(d => d.mac.toUpperCase() === mac.toUpperCase());
|
||||
if (!dev) return;
|
||||
$('deviceTypeModalMac').value = dev.mac;
|
||||
$('deviceTypeModalName').textContent = dev.name || 'Client sans nom';
|
||||
$('deviceTypeModalMacDisplay').textContent = dev.mac;
|
||||
|
||||
const statusEl = $('deviceTypeModalStatus');
|
||||
if (statusEl) {
|
||||
if (dev.blocked) {
|
||||
statusEl.className = 'pill';
|
||||
statusEl.style.cssText = 'background:rgba(255,107,107,.15);color:var(--red);border:1px solid rgba(255,107,107,.3);font-size:11px;font-weight:600';
|
||||
statusEl.textContent = '🔴 ' + t('status_blocked', 'Bloqué');
|
||||
} else if (dev.connected) {
|
||||
statusEl.className = 'pill pill-green pill-no-dot';
|
||||
statusEl.style.cssText = 'font-size:11px;font-weight:600';
|
||||
statusEl.textContent = '🟢 ' + t('status_connected', 'Connecté');
|
||||
} else {
|
||||
statusEl.className = 'pill';
|
||||
statusEl.style.cssText = 'background:var(--panel2);color:var(--muted);font-size:11px';
|
||||
@@ -14293,9 +14320,93 @@ ${vpnBadgeTopo}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/* --- Easter Egg Arcade Games (jeu:Tetris, jeu:dino, jeu:zipline) --- */
|
||||
let currentEasterEggGame = 'tetris';
|
||||
|
||||
window.openEasterEggModal = function (gameName = 'tetris') {
|
||||
const modal = $('modalEasterEggGames');
|
||||
if (!modal) return;
|
||||
modal.classList.add('active');
|
||||
modal.style.display = 'flex';
|
||||
switchEasterEggGame(gameName);
|
||||
};
|
||||
|
||||
window.closeEasterEggModal = function () {
|
||||
const modal = $('modalEasterEggGames');
|
||||
if (modal) {
|
||||
modal.classList.remove('active');
|
||||
modal.style.display = 'none';
|
||||
}
|
||||
const iframe = $('easterEggGameIframe');
|
||||
if (iframe) iframe.src = '';
|
||||
};
|
||||
|
||||
window.switchEasterEggGame = function (gameName) {
|
||||
currentEasterEggGame = gameName;
|
||||
const validGames = ['tetris', 'dino', 'zipline'];
|
||||
if (!validGames.includes(gameName)) gameName = 'tetris';
|
||||
|
||||
document.querySelectorAll('.game-switch-btn').forEach(btn => {
|
||||
const isActive = (btn.id === 'btnEggGame_' + gameName);
|
||||
btn.classList.toggle('active', isActive);
|
||||
});
|
||||
|
||||
const iframe = $('easterEggGameIframe');
|
||||
if (iframe) {
|
||||
iframe.src = '/jeux/' + gameName + '.html';
|
||||
setTimeout(() => {
|
||||
try { iframe.focus(); if (iframe.contentWindow) iframe.contentWindow.focus(); } catch (e) { }
|
||||
}, 150);
|
||||
}
|
||||
};
|
||||
|
||||
function parseEasterEggGameName(rawVal) {
|
||||
if (!rawVal || typeof rawVal !== 'string') return null;
|
||||
const clean = rawVal.trim();
|
||||
const m = clean.match(/^jeu\s*:\s*(.*)$/i) || (clean.toLowerCase() === 'jeu' ? ['', 'tetris'] : null);
|
||||
if (!m) return null;
|
||||
let g = (m[1] || 'tetris').trim().toLowerCase();
|
||||
if (g === 'dinausore' || g === 'dinosaure' || g === 'trex' || g === 't-rex' || g === 'chrome') return 'dino';
|
||||
if (g === 'zip' || g === 'zipline' || g === 'linkedin') return 'zipline';
|
||||
if (g === 'tetris' || g === '') return 'tetris';
|
||||
return g;
|
||||
}
|
||||
|
||||
function attachEasterEggTrigger(inputEl) {
|
||||
if (!inputEl) return;
|
||||
inputEl.addEventListener('keydown', (e) => {
|
||||
if (e.key === 'Enter') {
|
||||
const game = parseEasterEggGameName(inputEl.value);
|
||||
if (game) {
|
||||
e.preventDefault();
|
||||
e.stopPropagation();
|
||||
openEasterEggModal(game);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
// Attacher le déclencheur aux barres de recherche de l'onglet Avancé
|
||||
attachEasterEggTrigger($('vpnClientsSearchInput'));
|
||||
attachEasterEggTrigger($('packetFilterInput'));
|
||||
// Et pour une meilleure accessibilité, à la recherche des appareils également
|
||||
attachEasterEggTrigger($('devicesSearchInput'));
|
||||
|
||||
// Fermeture par la touche Échap et clic extérieur
|
||||
window.addEventListener('keydown', (e) => {
|
||||
if (e.key === 'Escape') {
|
||||
const m = $('modalEasterEggGames');
|
||||
if (m && m.classList.contains('active')) {
|
||||
closeEasterEggModal();
|
||||
}
|
||||
}
|
||||
});
|
||||
if ($('modalEasterEggGames')) {
|
||||
$('modalEasterEggGames').onclick = (e) => {
|
||||
if (e.target === $('modalEasterEggGames')) closeEasterEggModal();
|
||||
};
|
||||
}
|
||||
|
||||
</script>
|
||||
</body>
|
||||
|
||||
|
||||
Reference in new issue
Block a user