APmanageur Wi-Fi V1.0

This commit is contained in:
yoannmultigaming committed 2026-11-19 02:41:41 +01:00
1 parent 7eef4647a5
commit b8635b5162
5 files changed
+724 -21

No files matched your search

+199 -3
View File
@@ -5166,9 +5166,14 @@
<h3 style="margin:0;font-size:16px" data-i18n="backup_list_title">📂 Sauvegardes enregistrées</h3>
<div id="backupsListSummary" class="muted" style="font-size:12px;margin-top:3px">—</div>
</div>
<button id="btnRefreshBackups" type="button" class="secondary" onclick="refreshBackupsTab()" style="display:inline-flex;align-items:center;gap:6px" data-i18n="btn_refresh">
🔄 Actualiser
</button>
<div style="display:inline-flex;align-items:center;gap:8px;flex-wrap:wrap">
<button id="btnRefreshBackups" type="button" class="secondary" onclick="refreshBackupsTab()" style="display:inline-flex;align-items:center;gap:6px" data-i18n="btn_refresh">
🔄 Actualiser
</button>
<button id="btnOpenRemoteDriveModal" type="button" class="secondary" onclick="openRemoteDriveModal()" style="display:inline-flex;align-items:center;gap:6px" title="Voir, télécharger et gérer les sauvegardes présentes sur le stockage distant">
☁️ <span data-i18n="btn_view_remote_drive">Voir les fichiers du drive</span>
</button>
</div>
</div>
<div class="table-wrap">
<table>
@@ -5898,6 +5903,49 @@
</div>
</div>
</div>
<!-- Modal Fichiers du Drive / Stockage Distant -->
<div id="modalRemoteDriveFiles" class="modal-overlay">
<div class="modal-card" style="max-width:760px;width:95%">
<div class="modal-header">
<h2 style="margin:0;font-size:17px;display:flex;align-items:center;gap:8px">
<span id="remoteDriveModalIcon">☁️</span>
<span data-i18n="modal_remote_drive_title">Fichiers du stockage distant (Drive)</span>
</h2>
<button type="button" class="secondary" style="padding:4px 10px;font-size:16px" onclick="closeRemoteDriveModal()">✕</button>
</div>
<div class="modal-body" style="display:flex;flex-direction:column;gap:12px">
<div style="display:flex;justify-content:space-between;align-items:center;flex-wrap:wrap;gap:8px">
<div id="remoteDriveModalSub" class="muted" style="font-size:13px">
Chargement des fichiers distants…
</div>
<button type="button" class="secondary" onclick="loadRemoteDriveFiles()" style="padding:4px 10px;font-size:12px;display:inline-flex;align-items:center;gap:4px">
🔄 Actualiser le drive
</button>
</div>
<div id="remoteDriveActionMsg" style="display:none;padding:8px 12px;border-radius:8px;font-size:13px"></div>
<div class="table-wrap" style="max-height:400px;overflow-y:auto">
<table>
<thead>
<tr>
<th data-i18n="th_file">FICHIER</th>
<th data-i18n="th_date">DATE</th>
<th data-i18n="th_size">TAILLE</th>
<th data-i18n="th_status">STATUT</th>
<th style="text-align:right" data-i18n="th_actions">ACTIONS</th>
</tr>
</thead>
<tbody id="remoteDriveFilesTableBody">
<tr><td colspan="5" class="empty">Chargement…</td></tr>
</tbody>
</table>
</div>
</div>
<div class="modal-footer" style="display:flex;justify-content:flex-end">
<button type="button" class="secondary" onclick="closeRemoteDriveModal()" data-i18n="btn_close">Fermer</button>
</div>
</div>
</div>
</main>
<script src="https://cdnjs.cloudflare.com/ajax/libs/qrcodejs/1.0.0/qrcode.min.js" defer></script>
@@ -11170,6 +11218,154 @@ ${vpnBadgeTopo}
}
}
async function openRemoteDriveModal() {
const modal = $('modalRemoteDriveFiles');
if (!modal) return;
modal.classList.add('active');
modal.style.display = 'flex';
await loadRemoteDriveFiles();
}
function closeRemoteDriveModal() {
const modal = $('modalRemoteDriveFiles');
if (modal) {
modal.classList.remove('active');
modal.style.display = 'none';
}
}
async function loadRemoteDriveFiles() {
const tbody = $('remoteDriveFilesTableBody');
const sub = $('remoteDriveModalSub');
const iconEl = $('remoteDriveModalIcon');
const msg = $('remoteDriveActionMsg');
if (msg) msg.style.display = 'none';
if (tbody) tbody.innerHTML = `<tr><td colspan="5" class="empty"><span class="spin">🔄</span> ${escapeHtml(t('remote_drive_loading', 'Connexion et récupération des fichiers sur le drive…'))}</td></tr>`;
try {
const res = await apiFetch('/api/backups/remote/files');
const d = await res.json();
if (!res.ok) throw new Error(d.error || 'Erreur lors de la récupération des fichiers distants');
const prov = d.provider || 'ftp';
const pName = d.provider_name || prov.toUpperCase();
const provIconHtml = (typeof getRemoteProviderIconHtml === 'function') ? getRemoteProviderIconHtml(prov) : '☁️ ';
if (iconEl) iconEl.innerHTML = provIconHtml;
if (sub) {
sub.innerHTML = `<span>${provIconHtml}<strong>${escapeHtml(pName)}</strong> • ${d.count || 0} sauvegarde(s) détectée(s)</span>`;
}
if (!d.files || !d.files.length) {
if (tbody) tbody.innerHTML = `<tr><td colspan="5" class="empty">${escapeHtml(t('remote_drive_empty', 'Aucun fichier de sauvegarde trouvé sur le stockage distant.'))}</td></tr>`;
return;
}
if (tbody) {
tbody.innerHTML = d.files.map(f => {
const fname = f.name || '';
const safeArg = escapeHtml(fname).replace(/'/g, '&#39;');
const isLocal = !!f.is_local;
const localBadge = isLocal
? `<span class="pill pill-green pill-no-dot" style="font-size:10px;padding:2px 6px" title="${escapeHtml(t('backup_already_local', 'Déjà présent dans les sauvegardes locales'))}">💾 Local</span>`
: `<span class="pill pill-no-dot" style="font-size:10px;padding:2px 6px;opacity:0.75">☁️ Drive seul</span>`;
const pullBtn = isLocal
? `<button type="button" class="secondary" style="padding:4px 8px;font-size:11px" onclick="pullRemoteBackupToLocal('${safeArg}')" title="${escapeHtml(t('backup_reimport', 'Réimporter / Écraser la version locale'))}">📥 Réimporter</button>`
: `<button type="button" class="secondary" style="padding:4px 8px;font-size:11px;border-color:var(--blue);color:var(--blue)" onclick="pullRemoteBackupToLocal('${safeArg}')" title="${escapeHtml(t('backup_import_local', 'Rapatrier dans AP Manageur'))}">📥 Rapatrier</button>`;
return `<tr>
<td style="font-family:monospace;font-size:12px;word-break:break-all"><strong>${escapeHtml(fname)}</strong></td>
<td style="white-space:nowrap;font-size:12px" class="muted">${escapeHtml(f.date || '—')}</td>
<td style="white-space:nowrap;font-size:12px">${escapeHtml(f.size_str || '—')}</td>
<td>${localBadge}</td>
<td style="text-align:right;white-space:nowrap">
<div style="display:inline-flex;gap:6px;justify-content:flex-end">
<button type="button" class="secondary" style="padding:4px 8px;font-size:11px" onclick="downloadRemoteFileDirect('${safeArg}')" title="${escapeHtml(t('backup_btn_download_pc', 'Télécharger sur mon PC'))}">⬇️ PC</button>
${pullBtn}
<button type="button" class="secondary danger" style="padding:4px 8px;font-size:11px;border-color:rgba(239,68,68,0.45);color:var(--red)" onclick="deleteRemoteDriveFile('${safeArg}')" title="${escapeHtml(t('btn_delete', 'Supprimer du drive'))}">🗑️</button>
</div>
</td>
</tr>`;
}).join('');
}
} catch (e) {
if (tbody) {
tbody.innerHTML = `<tr><td colspan="5" class="empty" style="color:var(--red)">❌ ${escapeHtml(tErr(e.message))}</td></tr>`;
}
if (sub) sub.textContent = 'Erreur de connexion au stockage distant';
}
}
function downloadRemoteFileDirect(filename) {
window.location.href = '/api/backups/remote/file/download?file=' + encodeURIComponent(filename);
}
async function pullRemoteBackupToLocal(filename) {
const msg = $('remoteDriveActionMsg');
if (msg) {
msg.style.display = 'block';
msg.style.background = 'rgba(56,189,248,0.12)';
msg.style.color = 'var(--blue)';
msg.innerHTML = `<span class="spin">🔄</span> Rapatriement de « ${escapeHtml(filename)} » vers le serveur local…`;
}
try {
const res = await apiFetch('/api/backups/remote/file/pull', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({ filename })
});
const d = await res.json();
if (!res.ok) throw new Error(d.error || 'Erreur lors du rapatriement');
if (msg) {
msg.style.background = 'rgba(50,213,131,0.12)';
msg.style.color = 'var(--green)';
msg.textContent = '✓ ' + (d.message || 'Sauvegarde rapatriée avec succès !');
}
if (Array.isArray(d.backups)) renderServerBackupsTable(d.backups, serverBackupsTotalSize);
await loadRemoteDriveFiles();
} catch (e) {
if (msg) {
msg.style.background = 'rgba(239,68,68,0.12)';
msg.style.color = 'var(--red)';
msg.textContent = '❌ ' + tErr(e.message);
}
}
}
async function deleteRemoteDriveFile(filename) {
const confirmTxt = t('backup_confirm_remote_delete', 'Supprimer définitivement la sauvegarde « {file} » du stockage distant (Drive) ?\n\nAttention, cette action est irréversible.').replace('{file}', filename);
if (!confirm(confirmTxt)) return;
const msg = $('remoteDriveActionMsg');
if (msg) {
msg.style.display = 'block';
msg.style.background = 'rgba(239,68,68,0.12)';
msg.style.color = 'var(--red)';
msg.innerHTML = `<span class="spin">🔄</span> Suppression de « ${escapeHtml(filename)} » sur le drive…`;
}
try {
const res = await apiFetch('/api/backups/remote/file/delete', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({ filename })
});
const d = await res.json();
if (!res.ok) throw new Error(d.error || 'Erreur suppression distante');
if (msg) {
msg.style.background = 'rgba(50,213,131,0.12)';
msg.style.color = 'var(--green)';
msg.textContent = '✓ ' + (d.message || 'Fichier supprimé du drive.');
}
if (Array.isArray(d.backups)) renderServerBackupsTable(d.backups, serverBackupsTotalSize);
await loadRemoteDriveFiles();
} catch (e) {
if (msg) {
msg.style.background = 'rgba(239,68,68,0.12)';
msg.style.color = 'var(--red)';
msg.textContent = '❌ ' + tErr(e.message);
}
}
}
async function deleteServerBackup(filename) {
const confirmTxt = t('backup_confirm_delete', 'Supprimer définitivement la sauvegarde « {file} » ?').replace('{file}', filename);
if (!confirm(confirmTxt)) return;